Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: src/code-stubs.h

Issue 10701054: Enable stub generation using Hydrogen/Lithium (again) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index ae113f5729a58d26bcdfeffff0ee5011a2570954..b33ff3af1fa56a47af2d18943fc2a0f4b859e420 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -162,20 +162,23 @@ class CodeStub BASE_EMBEDDED {
// Lookup the code in the (possibly custom) cache.
bool FindCodeInCache(Code** code_out, Isolate* isolate);
+ // Returns information for computing the number key.
+ virtual Major MajorKey() = 0;
+ virtual int MinorKey() = 0;
+
protected:
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;
Jakob Kummerow 2012/11/28 16:28:22 Since both of these friends are also subclasses, w
danno 2012/11/30 16:23:24 Done.
+ friend class HydrogenCodeStub;
// 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) { }
@@ -184,10 +187,6 @@ class CodeStub BASE_EMBEDDED {
// registering stub in the stub cache.
virtual void Activate(Code* code) { }
- // Returns information for computing the number key.
- virtual Major MajorKey() = 0;
- virtual int MinorKey() = 0;
-
// BinaryOpStub needs to override this.
virtual int GetCodeKind();
@@ -232,6 +231,43 @@ 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;
+};
+
+
+struct CodeStubInterfaceDescriptor {
Jakob Kummerow 2012/11/28 16:28:22 Nice!
danno 2012/11/30 16:23:24 I like it too! On 2012/11/28 16:28:22, Jakob wrote
+ int number_of_register_params;
+ Register* register_params;
+ Handle<Code> deoptimization_handler;
+};
+
+
+class HGraph;
+class Register;
+class HydrogenCodeStub : public CodeStub {
+ public:
+ // Retrieve the code for the stub. Generate the code if needed.
+ virtual Handle<Code> GenerateCode() = 0;
+
+ virtual int GetCodeKind() { return Code::COMPILED_STUB; }
+
+ virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor(
+ Isolate* isolate) = 0;
+
+ protected:
+ Handle<Code> CodeFromGraph(HGraph* graph);
+};
+
+
// Helper interface to prepare to/restore after making runtime calls.
class RuntimeCallHelper {
public:
@@ -289,7 +325,7 @@ class NopRuntimeCallHelper : public RuntimeCallHelper {
};
-class StackCheckStub : public CodeStub {
+class StackCheckStub : public PlatformCodeStub {
public:
StackCheckStub() { }
@@ -301,7 +337,7 @@ class StackCheckStub : public CodeStub {
};
-class InterruptStub : public CodeStub {
+class InterruptStub : public PlatformCodeStub {
public:
InterruptStub() { }
@@ -313,7 +349,7 @@ class InterruptStub : public CodeStub {
};
-class ToNumberStub: public CodeStub {
+class ToNumberStub: public PlatformCodeStub {
public:
ToNumberStub() { }
@@ -325,7 +361,7 @@ class ToNumberStub: public CodeStub {
};
-class FastNewClosureStub : public CodeStub {
+class FastNewClosureStub : public PlatformCodeStub {
public:
explicit FastNewClosureStub(LanguageMode language_mode)
: language_mode_(language_mode) { }
@@ -341,7 +377,7 @@ class FastNewClosureStub : public CodeStub {
};
-class FastNewContextStub : public CodeStub {
+class FastNewContextStub : public PlatformCodeStub {
public:
static const int kMaximumSlots = 64;
@@ -359,7 +395,7 @@ class FastNewContextStub : public CodeStub {
};
-class FastNewBlockContextStub : public CodeStub {
+class FastNewBlockContextStub : public PlatformCodeStub {
public:
static const int kMaximumSlots = 64;
@@ -377,7 +413,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;
@@ -410,7 +446,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;
@@ -430,7 +466,7 @@ class FastCloneShallowObjectStub : public CodeStub {
};
-class InstanceofStub: public CodeStub {
+class InstanceofStub: public PlatformCodeStub {
public:
enum Flags {
kNoFlags = 0,
@@ -468,7 +504,7 @@ class InstanceofStub: public CodeStub {
};
-class MathPowStub: public CodeStub {
+class MathPowStub: public PlatformCodeStub {
public:
enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK};
@@ -484,7 +520,7 @@ class MathPowStub: public CodeStub {
};
-class BinaryOpStub: public CodeStub {
+class BinaryOpStub: public PlatformCodeStub {
public:
BinaryOpStub(Token::Value op, OverwriteMode mode)
: op_(op),
@@ -600,7 +636,7 @@ class BinaryOpStub: public CodeStub {
};
-class ICCompareStub: public CodeStub {
+class ICCompareStub: public PlatformCodeStub {
public:
ICCompareStub(Token::Value op,
CompareIC::State left,
@@ -666,7 +702,7 @@ class ICCompareStub: public CodeStub {
};
-class CEntryStub : public CodeStub {
+class CEntryStub : public PlatformCodeStub {
public:
explicit CEntryStub(int result_size,
SaveFPRegsMode save_doubles = kDontSaveFPRegs)
@@ -700,7 +736,7 @@ class CEntryStub : public CodeStub {
};
-class JSEntryStub : public CodeStub {
+class JSEntryStub : public PlatformCodeStub {
public:
JSEntryStub() { }
@@ -734,7 +770,7 @@ class JSConstructEntryStub : public JSEntryStub {
};
-class ArgumentsAccessStub: public CodeStub {
+class ArgumentsAccessStub: public PlatformCodeStub {
public:
enum Type {
READ_ELEMENT,
@@ -761,7 +797,7 @@ class ArgumentsAccessStub: public CodeStub {
};
-class RegExpExecStub: public CodeStub {
+class RegExpExecStub: public PlatformCodeStub {
public:
RegExpExecStub() { }
@@ -773,7 +809,7 @@ class RegExpExecStub: public CodeStub {
};
-class RegExpConstructResultStub: public CodeStub {
+class RegExpConstructResultStub: public PlatformCodeStub {
public:
RegExpConstructResultStub() { }
@@ -785,7 +821,7 @@ class RegExpConstructResultStub: public CodeStub {
};
-class CallFunctionStub: public CodeStub {
+class CallFunctionStub: public PlatformCodeStub {
public:
CallFunctionStub(int argc, CallFunctionFlags flags)
: argc_(argc), flags_(flags) { }
@@ -826,7 +862,7 @@ class CallFunctionStub: public CodeStub {
};
-class CallConstructStub: public CodeStub {
+class CallConstructStub: public PlatformCodeStub {
public:
explicit CallConstructStub(CallFunctionFlags flags) : flags_(flags) {}
@@ -1017,25 +1053,54 @@ class AllowStubCallsScope {
};
-class KeyedLoadElementStub : public CodeStub {
+class KeyedLoadDictionaryElementStub : public PlatformCodeStub {
public:
- explicit KeyedLoadElementStub(ElementsKind elements_kind)
- : elements_kind_(elements_kind)
- { }
+ explicit KeyedLoadDictionaryElementStub() {}
Jakob Kummerow 2012/11/28 16:28:22 nit: no need for "explicit"
danno 2012/11/30 16:23:24 Done.
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,
Jakob Kummerow 2012/11/28 16:28:22 nit: no need for "explicit"
danno 2012/11/30 16:23:24 Done.
+ ElementsKind elements_kind) {
+ bit_field_ = ElementsKindBits::encode(elements_kind);
Jakob Kummerow 2012/11/28 16:28:22 nit: elsewhere, we use the pattern: bit_field_ = F
danno 2012/11/30 16:23:24 Done.
+ bit_field_ = IsJSArrayBits::update(bit_field_, is_js_array);
+ }
+
+ 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_);
+ }
+
+ virtual Handle<Code> GenerateCode();
+
+ virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor(
+ Isolate* isolate);
+
+ 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,
@@ -1070,7 +1135,7 @@ class KeyedStoreElementStub : public CodeStub {
};
-class ToBooleanStub: public CodeStub {
+class ToBooleanStub: public PlatformCodeStub {
public:
enum Type {
UNDEFINED,
@@ -1140,7 +1205,7 @@ class ToBooleanStub: public CodeStub {
};
-class ElementsTransitionAndStoreStub : public CodeStub {
+class ElementsTransitionAndStoreStub : public PlatformCodeStub {
public:
ElementsTransitionAndStoreStub(ElementsKind from,
ElementsKind to,
@@ -1181,7 +1246,7 @@ class ElementsTransitionAndStoreStub : public CodeStub {
};
-class StoreArrayLiteralElementStub : public CodeStub {
+class StoreArrayLiteralElementStub : public PlatformCodeStub {
public:
StoreArrayLiteralElementStub()
: fp_registers_(CanUseFPRegisters()) { }
@@ -1200,7 +1265,7 @@ class StoreArrayLiteralElementStub : public CodeStub {
};
-class ProfileEntryHookStub : public CodeStub {
+class ProfileEntryHookStub : public PlatformCodeStub {
public:
explicit ProfileEntryHookStub() {}

Powered by Google App Engine
This is Rietveld 408576698