Index: src/code-stubs.h |
diff --git a/src/code-stubs.h b/src/code-stubs.h |
index e4384e7573d592af78df0d5166252db8eb087404..5ca9acdd5da0f81e0044c3dcfa08077953326e68 100644 |
--- a/src/code-stubs.h |
+++ b/src/code-stubs.h |
@@ -166,16 +166,14 @@ class CodeStub BASE_EMBEDDED { |
static bool CanUseFPRegisters(); |
private: |
- // Nonvirtual wrapper around the stub-specific Generate function. Call |
- // this function to set up the macro assembler and generate the code. |
- void GenerateCode(MacroAssembler* masm); |
+ friend class PlatformCodeStub; |
// Generates the assembler code for the stub. |
- virtual void Generate(MacroAssembler* masm) = 0; |
+ virtual Handle<Code> GenerateCode() = 0; |
// Perform bookkeeping required after code generation when stub code is |
// initially generated. |
- void RecordCodeGeneration(Code* code, MacroAssembler* masm); |
+ void RecordCodeGeneration(Code* code, Isolate* isolate); |
// Finish the code object after it has been generated. |
virtual void FinishCode(Handle<Code> code) { } |
@@ -230,6 +228,32 @@ class CodeStub BASE_EMBEDDED { |
}; |
+class PlatformCodeStub : public CodeStub { |
+ public: |
+ // Retrieve the code for the stub. Generate the code if needed. |
+ virtual Handle<Code> GenerateCode(); |
+ |
+ virtual int GetCodeKind() { return Code::STUB; } |
+ |
+ protected: |
+ // Generates the assembler code for the stub. |
+ virtual void Generate(MacroAssembler* masm) = 0; |
+}; |
+ |
+ |
+class HGraph; |
+class HydrogenCodeStub : public CodeStub { |
+ public: |
+ // Retrieve the code for the stub. Generate the code if needed. |
+ virtual Handle<Code> GenerateCode(); |
+ |
+ virtual int GetCodeKind() { return Code::COMPILED_STUB; } |
+ |
+ protected: |
+ virtual void Generate(HGraph* graph) = 0; |
+}; |
+ |
+ |
// Helper interface to prepare to/restore after making runtime calls. |
class RuntimeCallHelper { |
public: |
@@ -287,7 +311,7 @@ class NopRuntimeCallHelper : public RuntimeCallHelper { |
}; |
-class StackCheckStub : public CodeStub { |
+class StackCheckStub : public PlatformCodeStub { |
public: |
StackCheckStub() { } |
@@ -299,7 +323,7 @@ class StackCheckStub : public CodeStub { |
}; |
-class InterruptStub : public CodeStub { |
+class InterruptStub : public PlatformCodeStub { |
public: |
InterruptStub() { } |
@@ -311,7 +335,7 @@ class InterruptStub : public CodeStub { |
}; |
-class ToNumberStub: public CodeStub { |
+class ToNumberStub: public PlatformCodeStub { |
public: |
ToNumberStub() { } |
@@ -323,7 +347,7 @@ class ToNumberStub: public CodeStub { |
}; |
-class FastNewClosureStub : public CodeStub { |
+class FastNewClosureStub : public PlatformCodeStub { |
public: |
explicit FastNewClosureStub(LanguageMode language_mode) |
: language_mode_(language_mode) { } |
@@ -339,7 +363,7 @@ class FastNewClosureStub : public CodeStub { |
}; |
-class FastNewContextStub : public CodeStub { |
+class FastNewContextStub : public PlatformCodeStub { |
public: |
static const int kMaximumSlots = 64; |
@@ -357,7 +381,7 @@ class FastNewContextStub : public CodeStub { |
}; |
-class FastNewBlockContextStub : public CodeStub { |
+class FastNewBlockContextStub : public PlatformCodeStub { |
public: |
static const int kMaximumSlots = 64; |
@@ -375,7 +399,7 @@ class FastNewBlockContextStub : public CodeStub { |
}; |
-class FastCloneShallowArrayStub : public CodeStub { |
+class FastCloneShallowArrayStub : public PlatformCodeStub { |
public: |
// Maximum length of copied elements array. |
static const int kMaximumClonedLength = 8; |
@@ -408,7 +432,7 @@ class FastCloneShallowArrayStub : public CodeStub { |
}; |
-class FastCloneShallowObjectStub : public CodeStub { |
+class FastCloneShallowObjectStub : public PlatformCodeStub { |
public: |
// Maximum number of properties in copied object. |
static const int kMaximumClonedProperties = 6; |
@@ -428,7 +452,7 @@ class FastCloneShallowObjectStub : public CodeStub { |
}; |
-class InstanceofStub: public CodeStub { |
+class InstanceofStub: public PlatformCodeStub { |
public: |
enum Flags { |
kNoFlags = 0, |
@@ -466,7 +490,7 @@ class InstanceofStub: public CodeStub { |
}; |
-class MathPowStub: public CodeStub { |
+class MathPowStub: public PlatformCodeStub { |
public: |
enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK}; |
@@ -482,7 +506,7 @@ class MathPowStub: public CodeStub { |
}; |
-class ICCompareStub: public CodeStub { |
+class ICCompareStub: public PlatformCodeStub { |
public: |
ICCompareStub(Token::Value op, CompareIC::State state) |
: op_(op), state_(state) { |
@@ -543,7 +567,7 @@ enum NaNInformation { |
}; |
-class CompareStub: public CodeStub { |
+class CompareStub: public PlatformCodeStub { |
public: |
CompareStub(Condition cc, |
bool strict, |
@@ -625,7 +649,7 @@ class CompareStub: public CodeStub { |
}; |
-class CEntryStub : public CodeStub { |
+class CEntryStub : public PlatformCodeStub { |
public: |
explicit CEntryStub(int result_size, |
SaveFPRegsMode save_doubles = kDontSaveFPRegs) |
@@ -659,7 +683,7 @@ class CEntryStub : public CodeStub { |
}; |
-class JSEntryStub : public CodeStub { |
+class JSEntryStub : public PlatformCodeStub { |
public: |
JSEntryStub() { } |
@@ -693,7 +717,7 @@ class JSConstructEntryStub : public JSEntryStub { |
}; |
-class ArgumentsAccessStub: public CodeStub { |
+class ArgumentsAccessStub: public PlatformCodeStub { |
public: |
enum Type { |
READ_ELEMENT, |
@@ -720,7 +744,7 @@ class ArgumentsAccessStub: public CodeStub { |
}; |
-class RegExpExecStub: public CodeStub { |
+class RegExpExecStub: public PlatformCodeStub { |
public: |
RegExpExecStub() { } |
@@ -732,7 +756,7 @@ class RegExpExecStub: public CodeStub { |
}; |
-class RegExpConstructResultStub: public CodeStub { |
+class RegExpConstructResultStub: public PlatformCodeStub { |
public: |
RegExpConstructResultStub() { } |
@@ -744,7 +768,7 @@ class RegExpConstructResultStub: public CodeStub { |
}; |
-class CallFunctionStub: public CodeStub { |
+class CallFunctionStub: public PlatformCodeStub { |
public: |
CallFunctionStub(int argc, CallFunctionFlags flags) |
: argc_(argc), flags_(flags) { } |
@@ -785,7 +809,7 @@ class CallFunctionStub: public CodeStub { |
}; |
-class CallConstructStub: public CodeStub { |
+class CallConstructStub: public PlatformCodeStub { |
public: |
explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {} |
@@ -976,25 +1000,51 @@ class AllowStubCallsScope { |
}; |
-class KeyedLoadElementStub : public CodeStub { |
+class KeyedLoadDictionaryElementStub : public PlatformCodeStub { |
public: |
- explicit KeyedLoadElementStub(ElementsKind elements_kind) |
- : elements_kind_(elements_kind) |
- { } |
+ explicit KeyedLoadDictionaryElementStub() {} |
Major MajorKey() { return KeyedLoadElement; } |
- int MinorKey() { return elements_kind_; } |
+ int MinorKey() { return DICTIONARY_ELEMENTS; } |
void Generate(MacroAssembler* masm); |
private: |
- ElementsKind elements_kind_; |
+ DISALLOW_COPY_AND_ASSIGN(KeyedLoadDictionaryElementStub); |
+}; |
+ |
+ |
+class KeyedLoadFastElementStub : public HydrogenCodeStub { |
+ public: |
+ explicit KeyedLoadFastElementStub(bool is_js_array, |
+ ElementsKind elements_kind) { |
+ bit_field_ = ElementsKindBits::encode(elements_kind); |
+ bit_field_ = IsJSArrayBits::update(bit_field_, is_js_array); |
+ } |
+ |
+ virtual void Generate(HGraph* graph); |
+ |
+ Major MajorKey() { return KeyedLoadElement; } |
+ int MinorKey() { return bit_field_; } |
+ |
+ bool is_js_array() const { |
+ return IsJSArrayBits::decode(bit_field_); |
+ } |
+ |
+ ElementsKind elements_kind() const { |
+ return ElementsKindBits::decode(bit_field_); |
+ } |
+ |
+ private: |
+ class IsJSArrayBits: public BitField<bool, 8, 1> {}; |
+ class ElementsKindBits: public BitField<ElementsKind, 0, 8> {}; |
+ uint32_t bit_field_; |
- DISALLOW_COPY_AND_ASSIGN(KeyedLoadElementStub); |
+ DISALLOW_COPY_AND_ASSIGN(KeyedLoadFastElementStub); |
}; |
-class KeyedStoreElementStub : public CodeStub { |
+class KeyedStoreElementStub : public PlatformCodeStub { |
public: |
KeyedStoreElementStub(bool is_js_array, |
ElementsKind elements_kind, |
@@ -1029,7 +1079,7 @@ class KeyedStoreElementStub : public CodeStub { |
}; |
-class ToBooleanStub: public CodeStub { |
+class ToBooleanStub: public PlatformCodeStub { |
public: |
enum Type { |
UNDEFINED, |
@@ -1096,7 +1146,7 @@ class ToBooleanStub: public CodeStub { |
}; |
-class ElementsTransitionAndStoreStub : public CodeStub { |
+class ElementsTransitionAndStoreStub : public PlatformCodeStub { |
public: |
ElementsTransitionAndStoreStub(ElementsKind from, |
ElementsKind to, |
@@ -1137,7 +1187,7 @@ class ElementsTransitionAndStoreStub : public CodeStub { |
}; |
-class StoreArrayLiteralElementStub : public CodeStub { |
+class StoreArrayLiteralElementStub : public PlatformCodeStub { |
public: |
StoreArrayLiteralElementStub() |
: fp_registers_(CanUseFPRegisters()) { } |
@@ -1156,7 +1206,7 @@ class StoreArrayLiteralElementStub : public CodeStub { |
}; |
-class ProfileEntryHookStub : public CodeStub { |
+class ProfileEntryHookStub : public PlatformCodeStub { |
public: |
explicit ProfileEntryHookStub() {} |