28 #ifndef V8_CODE_STUBS_H_
29 #define V8_CODE_STUBS_H_
39 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \
51 V(StoreBufferOverflow) \
53 V(TranscendentalCache) \
56 V(WriteInt32ToHeapNumber) \
61 V(FastNewBlockContext) \
62 V(FastCloneShallowArray) \
63 V(FastCloneShallowObject) \
67 V(RegExpConstructResult) \
72 V(KeyedStoreElement) \
73 V(DebuggerStatement) \
74 V(StringDictionaryLookup) \
75 V(ElementsTransitionAndStore) \
76 V(StoreArrayLiteralElement) \
80 #ifdef V8_TARGET_ARCH_ARM
81 #define CODE_STUB_LIST_ARM(V) \
88 #define CODE_STUB_LIST_ARM(V)
92 #ifdef V8_TARGET_ARCH_MIPS
93 #define CODE_STUB_LIST_MIPS(V) \
97 #define CODE_STUB_LIST_MIPS(V)
101 #define CODE_STUB_LIST(V) \
102 CODE_STUB_LIST_ALL_PLATFORMS(V) \
103 CODE_STUB_LIST_ARM(V) \
104 CODE_STUB_LIST_MIPS(V)
115 #define DEF_ENUM(name) name,
126 return static_cast<Major>(MajorKeyBits::decode(key));
129 return MinorKeyBits::decode(key);
137 static const char* MajorName(Major major_key,
bool allow_unknown_keys);
142 bool is_pregenerated = IsPregenerated();
144 CHECK(!is_pregenerated || FindCodeInCache(&code));
145 return is_pregenerated;
151 static void GenerateStubsAheadOfTime();
152 static void GenerateFPStubs();
163 bool FindCodeInCache(
Code** code_out);
166 static bool CanUseFPRegisters();
185 virtual void Activate(Code*
code) { }
188 virtual Major MajorKey() = 0;
189 virtual int MinorKey() = 0;
192 virtual int GetCodeKind();
202 virtual void AddToSpecialCache(Handle<Code> new_object) { }
205 virtual bool FindCodeInSpecialCache(Code** code_out) {
return false; }
208 virtual bool UseSpecialCache() {
return false; }
211 SmartArrayPointer<const char> GetName();
212 virtual void PrintName(StringStream* stream);
216 virtual bool NeedsImmovableCode() {
return false; }
220 ASSERT(static_cast<int>(MajorKey()) < NUMBER_OF_IDS);
221 return MinorKeyBits::encode(MinorKey()) |
222 MajorKeyBits::encode(MajorKey());
225 class MajorKeyBits:
public BitField<uint32_t, 0, kStubMajorKeyBits> {};
226 class MinorKeyBits:
public BitField<uint32_t,
227 kStubMajorKeyBits, kStubMinorKeyBits> {};
229 friend class BreakPointIterator;
251 #if V8_TARGET_ARCH_IA32
253 #elif V8_TARGET_ARCH_X64
255 #elif V8_TARGET_ARCH_ARM
257 #elif V8_TARGET_ARCH_MIPS
260 #error Unsupported target architecture.
297 Major MajorKey() {
return StackCheck; }
298 int MinorKey() {
return 0; }
309 Major MajorKey() {
return Interrupt; }
310 int MinorKey() {
return 0; }
321 Major MajorKey() {
return ToNumber; }
322 int MinorKey() {
return 0; }
329 : language_mode_(language_mode) { }
334 Major MajorKey() {
return FastNewClosure; }
355 Major MajorKey() {
return FastNewContext; }
356 int MinorKey() {
return slots_; }
373 Major MajorKey() {
return FastNewBlockContext; }
374 int MinorKey() {
return slots_; }
403 Major MajorKey() {
return FastCloneShallowArray; }
405 ASSERT(mode_ == 0 || mode_ == 1 || mode_ == 2 || mode_ == 3);
406 return length_ * 4 + mode_;
426 Major MajorKey() {
return FastCloneShallowObject; }
427 int MinorKey() {
return length_; }
448 Major MajorKey() {
return Instanceof; }
449 int MinorKey() {
return static_cast<int>(flags_); }
451 bool HasArgsInRegisters()
const {
455 bool HasCallSiteInlineCheck()
const {
459 bool ReturnTrueFalseObject()
const {
463 virtual void PrintName(StringStream* stream);
474 : exponent_type_(exponent_type) { }
478 virtual CodeStub::Major MajorKey() {
return MathPow; }
479 virtual int MinorKey() {
return exponent_type_; }
488 : op_(op), state_(state) {
497 class OpField:
public BitField<int, 0, 3> { };
498 class StateField:
public BitField<int, 3, 5> { };
500 virtual void FinishCode(Handle<Code>
code) {
501 code->set_compare_state(state_);
502 code->set_compare_operation(op_ -
Token::EQ);
505 virtual CodeStub::Major MajorKey() {
return CompareIC; }
506 virtual int MinorKey();
508 virtual int GetCodeKind() {
return Code::COMPARE_IC; }
510 void GenerateSmis(MacroAssembler* masm);
511 void GenerateHeapNumbers(MacroAssembler* masm);
512 void GenerateSymbols(MacroAssembler* masm);
513 void GenerateStrings(MacroAssembler* masm);
514 void GenerateObjects(MacroAssembler* masm);
515 void GenerateMiss(MacroAssembler* masm);
516 void GenerateKnownObjects(MacroAssembler* masm);
518 bool strict()
const {
return op_ == Token::EQ_STRICT; }
521 virtual void AddToSpecialCache(Handle<Code> new_object);
522 virtual bool FindCodeInSpecialCache(Code** code_out);
527 Handle<Map> known_map_;
586 bool include_number_compare_;
589 bool include_smi_compare_;
600 class StrictField:
public BitField<bool, 0, 1> {};
601 class NeverNanNanField:
public BitField<bool, 1, 1> {};
602 class IncludeNumberCompareField:
public BitField<bool, 2, 1> {};
603 class IncludeSmiCompareField:
public BitField<bool, 3, 1> {};
604 class RegisterField:
public BitField<bool, 4, 1> {};
605 class ConditionField:
public BitField<int, 5, 11> {};
607 Major MajorKey() {
return Compare; }
611 virtual int GetCodeKind() {
return Code::COMPARE_IC; }
612 virtual void FinishCode(Handle<Code> code) {
617 void BranchIfNonSymbol(MacroAssembler* masm,
624 virtual void PrintName(StringStream* stream);
632 : result_size_(result_size), save_doubles_(save_doubles) { }
645 Label* throw_normal_exception,
646 Label* throw_termination_exception,
647 Label* throw_out_of_memory_exception,
649 bool always_allocate_scope);
652 const int result_size_;
655 Major MajorKey() {
return CEntry; }
658 bool NeedsImmovableCode();
672 Major MajorKey() {
return JSEntry; }
673 int MinorKey() {
return 0; }
675 virtual void FinishCode(Handle<Code> code);
688 int MinorKey() {
return 1; }
690 virtual void PrintName(StringStream* stream) {
691 stream->Add(
"JSConstructEntryStub");
710 Major MajorKey() {
return ArgumentsAccess; }
711 int MinorKey() {
return type_; }
713 void Generate(MacroAssembler* masm);
714 void GenerateReadElement(MacroAssembler* masm);
715 void GenerateNewStrict(MacroAssembler* masm);
716 void GenerateNewNonStrictFast(MacroAssembler* masm);
717 void GenerateNewNonStrictSlow(MacroAssembler* masm);
719 virtual void PrintName(StringStream* stream);
728 Major MajorKey() {
return RegExpExec; }
729 int MinorKey() {
return 0; }
731 void Generate(MacroAssembler* masm);
740 Major MajorKey() {
return RegExpConstructResult; }
741 int MinorKey() {
return 0; }
743 void Generate(MacroAssembler* masm);
750 : argc_(argc), flags_(flags) { }
755 code->set_has_function_cache(RecordCallTarget());
759 return ArgcBits::decode(minor_key);
769 class FlagBits:
public BitField<CallFunctionFlags, 0, 2> {};
770 class ArgcBits:
public BitField<unsigned, 2, 32 - 2> {};
772 Major MajorKey() {
return CallFunction; }
775 return FlagBits::encode(flags_) | ArgcBits::encode(argc_);
778 bool ReceiverMightBeImplicit() {
782 bool RecordCallTarget() {
795 code->set_has_function_cache(RecordCallTarget());
803 Major MajorKey() {
return CallConstruct; }
804 int MinorKey() {
return flags_; }
806 bool RecordCallTarget() {
838 Label* receiver_not_string,
839 Label* index_not_number,
840 Label* index_out_of_range,
845 receiver_not_string_(receiver_not_string),
846 index_not_number_(index_not_number),
847 index_out_of_range_(index_out_of_range),
848 index_flags_(index_flags) {
868 Label* receiver_not_string_;
869 Label* index_not_number_;
870 Label* index_out_of_range_;
875 Label index_not_smi_;
876 Label got_smi_index_;
930 Label* receiver_not_string,
931 Label* index_not_number,
932 Label* index_out_of_range,
934 : char_code_at_generator_(object,
941 char_from_code_generator_(scratch, result) {}
964 : masm_(masm), previous_allow_(masm->allow_stub_calls()) {
973 bool previous_allow_;
982 : elements_kind_(elements_kind)
1002 : is_js_array_(is_js_array),
1003 elements_kind_(elements_kind),
1004 grow_mode_(grow_mode),
1005 fp_registers_(CanUseFPRegisters()) { }
1009 return ElementsKindBits::encode(elements_kind_) |
1010 IsJSArrayBits::encode(is_js_array_) |
1011 GrowModeBits::encode(grow_mode_) |
1012 FPRegisters::encode(fp_registers_);
1018 class ElementsKindBits:
public BitField<ElementsKind, 0, 8> {};
1019 class GrowModeBits:
public BitField<KeyedAccessGrowMode, 8, 1> {};
1020 class IsJSArrayBits:
public BitField<bool, 9, 1> {};
1021 class FPRegisters:
public BitField<bool, 10, 1> {};
1072 : tos_(tos), types_(types) { }
1081 Major MajorKey() {
return ToBoolean; }
1084 virtual void FinishCode(Handle<Code> code) {
1085 code->set_to_boolean_state(types_.
ToByte());
1088 void CheckOddball(MacroAssembler* masm,
1092 void GenerateTypeTransition(MacroAssembler* masm);
1108 is_jsarray_(is_jsarray),
1109 strict_mode_(strict_mode),
1110 grow_mode_(grow_mode) {}
1113 class FromBits:
public BitField<ElementsKind, 0, 8> {};
1114 class ToBits:
public BitField<ElementsKind, 8, 8> {};
1115 class IsJSArrayBits:
public BitField<bool, 16, 1> {};
1116 class StrictModeBits:
public BitField<StrictModeFlag, 17, 1> {};
1117 class GrowModeBits:
public BitField<KeyedAccessGrowMode, 18, 1> {};
1119 Major MajorKey() {
return ElementsTransitionAndStore; }
1121 return FromBits::encode(from_) |
1122 ToBits::encode(to_) |
1123 IsJSArrayBits::encode(is_jsarray_) |
1124 StrictModeBits::encode(strict_mode_) |
1125 GrowModeBits::encode(grow_mode_);
1128 void Generate(MacroAssembler* masm);
1143 : fp_registers_(CanUseFPRegisters()) { }
1146 class FPRegisters:
public BitField<bool, 0, 1> {};
1148 Major MajorKey() {
return StoreArrayLiteralElement; }
1149 int MinorKey() {
return FPRegisters::encode(fp_registers_); }
1151 void Generate(MacroAssembler* masm);
1175 static void EntryHookTrampoline(intptr_t
function,
1176 intptr_t stack_pointer);
1178 Major MajorKey() {
return ProfileEntryHook; }
1179 int MinorKey() {
return 0; }
1181 void Generate(MacroAssembler* masm);
1191 #endif // V8_CODE_STUBS_H_
MathPowStub(ExponentType exponent_type)
void GenerateFast(MacroAssembler *masm)
void GenerateSlow(MacroAssembler *masm, const RuntimeCallHelper &call_helper)
virtual void FinishCode(Handle< Code > code)
void GenerateFast(MacroAssembler *masm)
virtual void AfterCall(MacroAssembler *masm) const
void GenerateSlow(MacroAssembler *masm, const RuntimeCallHelper &call_helper)
CallFunctionStub(int argc, CallFunctionFlags flags)
FastCloneShallowObjectStub(int length)
virtual void FinishCode(Handle< Code > code)
virtual bool SometimesSetsUpAFrame()
void Generate(MacroAssembler *masm)
StringCharFromCodeGenerator(Register code, Register result)
static int ExtractArgcFromMinorKey(int minor_key)
static bool IsCompareOp(Value op)
virtual void PrintName(StringStream *stream)
void set_known_map(Handle< Map > map)
bool Record(Handle< Object > object)
CompareStub(Condition cc, bool strict, CompareFlags flags, Register lhs, Register rhs)
void Generate(MacroAssembler *masm)
void Generate(MacroAssembler *masm)
void set_allow_stub_calls(bool value)
virtual bool IsPregenerated()
void Generate(MacroAssembler *masm)
bool CanBeUndetectable() const
#define ASSERT(condition)
#define ASSERT_GE(v1, v2)
virtual void AfterCall(MacroAssembler *masm) const
static bool SetFunctionEntryHook(FunctionEntryHook entry_hook)
InstanceofStub(Flags flags)
static const int kMaximumSlots
virtual int GetCodeKind()
void Generate(MacroAssembler *masm)
virtual bool SometimesSetsUpAFrame()
void Generate(MacroAssembler *masm)
KeyedStoreElementStub(bool is_js_array, ElementsKind elements_kind, KeyedAccessGrowMode grow_mode)
STATIC_ASSERT(NUMBER_OF_TYPES<=8)
void(* FunctionEntryHook)(uintptr_t function, uintptr_t return_addr_location)
virtual void AfterCall(MacroAssembler *masm) const =0
virtual bool IsPregenerated()
static Condition ComputeCondition(Token::Value op)
CallConstructStub(CallFunctionFlags flags)
void Generate(MacroAssembler *masm)
virtual void BeforeCall(MacroAssembler *masm) const =0
StringCharCodeAtGenerator(Register object, Register index, Register result, Label *receiver_not_string, Label *index_not_number, Label *index_out_of_range, StringIndexFlags index_flags)
StringCharAtGenerator(Register object, Register index, Register scratch, Register result, Label *receiver_not_string, Label *index_not_number, Label *index_out_of_range, StringIndexFlags index_flags)
virtual void BeforeCall(MacroAssembler *masm) const
int Compare(const T &a, const T &b)
virtual ~RuntimeCallHelper()
static void MaybeCallEntryHook(MacroAssembler *masm)
FastNewBlockContextStub(int slots)
ToBooleanStub(Register tos, Types types=Types())
void Generate(MacroAssembler *masm)
#define ASSERT_LE(v1, v2)
ElementsTransitionAndStoreStub(ElementsKind from, ElementsKind to, bool is_jsarray, StrictModeFlag strict_mode, KeyedAccessGrowMode grow_mode)
AllowStubCallsScope(MacroAssembler *masm, bool allow)
bool CompilingCallsToThisStubIsGCSafe()
void Generate(MacroAssembler *masm)
void GenerateSlow(MacroAssembler *masm, const RuntimeCallHelper &call_helper)
virtual void Generate(MacroAssembler *masm)
virtual bool SometimesSetsUpAFrame()
ArgumentsAccessStub(Type type)
void Generate(MacroAssembler *masm)
int ToNumber(Register reg)
bool is(Register reg) const
static Major GetMajorKey(Code *code_stub)
void Generate(MacroAssembler *masm)
bool Contains(E element) const
RegExpConstructResultStub()
void GenerateBody(MacroAssembler *masm, bool is_construct)
FastNewClosureStub(LanguageMode language_mode)
static void GenerateAheadOfTime()
static const int kMaximumSlots
FastNewContextStub(int slots)
void Generate(MacroAssembler *masm)
CompareStub(Condition cc, bool strict, CompareFlags flags)
void Generate(MacroAssembler *masm)
void GenerateFast(MacroAssembler *masm)
static const int kMaximumClonedProperties
void TraceTransition(Types to) const
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
FastCloneShallowArrayStub(Mode mode, int length)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
bool Contains(Type type) const
KeyedLoadElementStub(ElementsKind elements_kind)
static Major MajorKeyFromKey(uint32_t key)
virtual void Generate(MacroAssembler *masm)
virtual void BeforeCall(MacroAssembler *masm) const
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
#define CODE_STUB_LIST(V)
void Generate(MacroAssembler *masm)
void Print(StringStream *stream) const
StoreArrayLiteralElementStub()
void Generate(MacroAssembler *masm)
CEntryStub(int result_size, SaveFPRegsMode save_doubles=kDontSaveFPRegs)
void Generate(MacroAssembler *masm)
static const int kMaximumClonedLength
void Generate(MacroAssembler *masm)
ICCompareStub(Token::Value op, CompareIC::State state)
static int MinorKeyFromKey(uint32_t key)
void Generate(MacroAssembler *masm)