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)
79 #ifdef V8_TARGET_ARCH_ARM
80 #define CODE_STUB_LIST_ARM(V) \
87 #define CODE_STUB_LIST_ARM(V)
91 #ifdef V8_TARGET_ARCH_MIPS
92 #define CODE_STUB_LIST_MIPS(V) \
96 #define CODE_STUB_LIST_MIPS(V)
100 #define CODE_STUB_LIST(V) \
101 CODE_STUB_LIST_ALL_PLATFORMS(V) \
102 CODE_STUB_LIST_ARM(V) \
103 CODE_STUB_LIST_MIPS(V)
114 #define DEF_ENUM(name) name,
125 return static_cast<Major>(MajorKeyBits::decode(key));
128 return MinorKeyBits::decode(key);
136 static const char* MajorName(Major major_key,
bool allow_unknown_keys);
141 bool is_pregenerated = IsPregenerated();
143 CHECK(!is_pregenerated || FindCodeInCache(&code));
144 return is_pregenerated;
150 static void GenerateStubsAheadOfTime();
151 static void GenerateFPStubs();
162 bool FindCodeInCache(
Code** code_out);
165 static const int kMajorBits = 6;
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, kMajorBits> {};
226 class MinorKeyBits:
public BitField<uint32_t, kMajorBits, kMinorBits> {};
228 friend class BreakPointIterator;
250 #if V8_TARGET_ARCH_IA32
252 #elif V8_TARGET_ARCH_X64
254 #elif V8_TARGET_ARCH_ARM
256 #elif V8_TARGET_ARCH_MIPS
259 #error Unsupported target architecture.
296 Major MajorKey() {
return StackCheck; }
297 int MinorKey() {
return 0; }
308 Major MajorKey() {
return Interrupt; }
309 int MinorKey() {
return 0; }
320 Major MajorKey() {
return ToNumber; }
321 int MinorKey() {
return 0; }
328 : language_mode_(language_mode) { }
333 Major MajorKey() {
return FastNewClosure; }
354 Major MajorKey() {
return FastNewContext; }
355 int MinorKey() {
return slots_; }
372 Major MajorKey() {
return FastNewBlockContext; }
373 int MinorKey() {
return slots_; }
402 Major MajorKey() {
return FastCloneShallowArray; }
404 ASSERT(mode_ == 0 || mode_ == 1 || mode_ == 2 || mode_ == 3);
405 return length_ * 4 + mode_;
425 Major MajorKey() {
return FastCloneShallowObject; }
426 int MinorKey() {
return length_; }
447 Major MajorKey() {
return Instanceof; }
448 int MinorKey() {
return static_cast<int>(flags_); }
450 bool HasArgsInRegisters()
const {
454 bool HasCallSiteInlineCheck()
const {
458 bool ReturnTrueFalseObject()
const {
462 virtual void PrintName(StringStream* stream);
473 : exponent_type_(exponent_type) { }
477 virtual CodeStub::Major MajorKey() {
return MathPow; }
478 virtual int MinorKey() {
return exponent_type_; }
487 : op_(op), state_(state) {
496 class OpField:
public BitField<int, 0, 3> { };
497 class StateField:
public BitField<int, 3, 5> { };
499 virtual void FinishCode(Handle<Code> code) {
500 code->set_compare_state(state_);
501 code->set_compare_operation(op_);
504 virtual CodeStub::Major MajorKey() {
return CompareIC; }
505 virtual int MinorKey();
509 void GenerateSmis(MacroAssembler* masm);
510 void GenerateHeapNumbers(MacroAssembler* masm);
511 void GenerateSymbols(MacroAssembler* masm);
512 void GenerateStrings(MacroAssembler* masm);
513 void GenerateObjects(MacroAssembler* masm);
514 void GenerateMiss(MacroAssembler* masm);
515 void GenerateKnownObjects(MacroAssembler* masm);
517 bool strict()
const {
return op_ == Token::EQ_STRICT; }
520 virtual void AddToSpecialCache(Handle<Code> new_object);
521 virtual bool FindCodeInSpecialCache(Code** code_out);
526 Handle<Map> known_map_;
585 bool include_number_compare_;
588 bool include_smi_compare_;
599 class StrictField:
public BitField<bool, 0, 1> {};
600 class NeverNanNanField:
public BitField<bool, 1, 1> {};
601 class IncludeNumberCompareField:
public BitField<bool, 2, 1> {};
602 class IncludeSmiCompareField:
public BitField<bool, 3, 1> {};
603 class RegisterField:
public BitField<bool, 4, 1> {};
604 class ConditionField:
public BitField<int, 5, 11> {};
606 Major MajorKey() {
return Compare; }
611 virtual void FinishCode(Handle<Code> code) {
616 void BranchIfNonSymbol(MacroAssembler* masm,
623 virtual void PrintName(StringStream* stream);
631 : result_size_(result_size), save_doubles_(save_doubles) { }
644 Label* throw_normal_exception,
645 Label* throw_termination_exception,
646 Label* throw_out_of_memory_exception,
648 bool always_allocate_scope);
651 const int result_size_;
654 Major MajorKey() {
return CEntry; }
657 bool NeedsImmovableCode();
671 Major MajorKey() {
return JSEntry; }
672 int MinorKey() {
return 0; }
674 virtual void FinishCode(Handle<Code> code);
687 int MinorKey() {
return 1; }
689 virtual void PrintName(StringStream* stream) {
690 stream->Add(
"JSConstructEntryStub");
709 Major MajorKey() {
return ArgumentsAccess; }
710 int MinorKey() {
return type_; }
712 void Generate(MacroAssembler* masm);
713 void GenerateReadElement(MacroAssembler* masm);
714 void GenerateNewStrict(MacroAssembler* masm);
715 void GenerateNewNonStrictFast(MacroAssembler* masm);
716 void GenerateNewNonStrictSlow(MacroAssembler* masm);
718 virtual void PrintName(StringStream* stream);
727 Major MajorKey() {
return RegExpExec; }
728 int MinorKey() {
return 0; }
730 void Generate(MacroAssembler* masm);
739 Major MajorKey() {
return RegExpConstructResult; }
740 int MinorKey() {
return 0; }
742 void Generate(MacroAssembler* masm);
749 : argc_(argc), flags_(flags) { }
754 code->set_has_function_cache(RecordCallTarget());
758 return ArgcBits::decode(minor_key);
768 class FlagBits:
public BitField<CallFunctionFlags, 0, 2> {};
769 class ArgcBits:
public BitField<unsigned, 2, 32 - 2> {};
771 Major MajorKey() {
return CallFunction; }
774 return FlagBits::encode(flags_) | ArgcBits::encode(argc_);
777 bool ReceiverMightBeImplicit() {
781 bool RecordCallTarget() {
794 code->set_has_function_cache(RecordCallTarget());
802 Major MajorKey() {
return CallConstruct; }
803 int MinorKey() {
return flags_; }
805 bool RecordCallTarget() {
837 Label* receiver_not_string,
838 Label* index_not_number,
839 Label* index_out_of_range,
844 receiver_not_string_(receiver_not_string),
845 index_not_number_(index_not_number),
846 index_out_of_range_(index_out_of_range),
847 index_flags_(index_flags) {
867 Label* receiver_not_string_;
868 Label* index_not_number_;
869 Label* index_out_of_range_;
874 Label index_not_smi_;
875 Label got_smi_index_;
929 Label* receiver_not_string,
930 Label* index_not_number,
931 Label* index_out_of_range,
933 : char_code_at_generator_(object,
940 char_from_code_generator_(scratch, result) {}
963 : masm_(masm), previous_allow_(masm->allow_stub_calls()) {
972 bool previous_allow_;
981 : elements_kind_(elements_kind)
1001 : is_js_array_(is_js_array),
1002 elements_kind_(elements_kind),
1003 grow_mode_(grow_mode) { }
1007 return ElementsKindBits::encode(elements_kind_) |
1008 IsJSArrayBits::encode(is_js_array_) |
1009 GrowModeBits::encode(grow_mode_);
1015 class ElementsKindBits:
public BitField<ElementsKind, 0, 8> {};
1016 class GrowModeBits:
public BitField<KeyedAccessGrowMode, 8, 1> {};
1017 class IsJSArrayBits:
public BitField<bool, 9, 1> {};
1067 : tos_(tos), types_(types) { }
1076 Major MajorKey() {
return ToBoolean; }
1079 virtual void FinishCode(Handle<Code> code) {
1080 code->set_to_boolean_state(types_.
ToByte());
1083 void CheckOddball(MacroAssembler* masm,
1087 void GenerateTypeTransition(MacroAssembler* masm);
1103 is_jsarray_(is_jsarray),
1104 strict_mode_(strict_mode),
1105 grow_mode_(grow_mode) {}
1108 class FromBits:
public BitField<ElementsKind, 0, 8> {};
1109 class ToBits:
public BitField<ElementsKind, 8, 8> {};
1110 class IsJSArrayBits:
public BitField<bool, 16, 1> {};
1111 class StrictModeBits:
public BitField<StrictModeFlag, 17, 1> {};
1112 class GrowModeBits:
public BitField<KeyedAccessGrowMode, 18, 1> {};
1114 Major MajorKey() {
return ElementsTransitionAndStore; }
1116 return FromBits::encode(from_) |
1117 ToBits::encode(to_) |
1118 IsJSArrayBits::encode(is_jsarray_) |
1119 StrictModeBits::encode(strict_mode_) |
1120 GrowModeBits::encode(grow_mode_);
1123 void Generate(MacroAssembler* masm);
1140 Major MajorKey() {
return StoreArrayLiteralElement; }
1141 int MinorKey() {
return 0; }
1143 void Generate(MacroAssembler* masm);
1150 #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)
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
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)
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()
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)
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 trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt 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 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
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
FastCloneShallowArrayStub(Mode mode, int length)
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
#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)