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

Unified Diff: src/code-stubs.h

Issue 12385014: Hydrogen stubs for array constructors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: We still generated the arrays with feature flag off. Fixed. Created 7 years, 8 months 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
« no previous file with comments | « src/builtins.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index 55d7e5d809d12227531bded89766b17576d1e3e4..09dce88e190d991311d5c444fbaf6428907401c9 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -83,6 +83,7 @@ namespace internal {
V(TransitionElementsKind) \
V(StoreArrayLiteralElement) \
V(StubFailureTrampoline) \
+ V(ArrayConstructor) \
V(ProfileEntryHook) \
/* IC Handler stubs */ \
V(LoadField)
@@ -266,6 +267,9 @@ struct CodeStubInterfaceDescriptor {
CodeStubInterfaceDescriptor();
int register_param_count_;
const Register* stack_parameter_count_;
+ // if hint_stack_parameter_count_ > 0, the code stub can optimize the
+ // return sequence. Default value is -1, which means it is ignored.
+ int hint_stack_parameter_count_;
StubFunctionMode function_mode_;
Register* register_params_;
Address deoptimization_handler_;
@@ -277,8 +281,17 @@ struct CodeStubInterfaceDescriptor {
}
return register_param_count_;
}
+
+ bool initialized() const { return register_param_count_ >= 0; }
};
+// A helper to make up for the fact that type Register is not fully
+// defined outside of the platform directories
+#define DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index) \
+ ((index) == (descriptor)->register_param_count_) \
+ ? *((descriptor)->stack_parameter_count_) \
+ : (descriptor)->register_params_[(index)]
+
class HydrogenCodeStub : public CodeStub {
public:
@@ -622,6 +635,22 @@ class InstanceofStub: public PlatformCodeStub {
};
+class ArrayConstructorStub: public PlatformCodeStub {
+ public:
+ enum ArgumentCountKey { ANY, NONE, ONE, MORE_THAN_ONE };
+ ArrayConstructorStub(Isolate* isolate, int argument_count);
+ explicit ArrayConstructorStub(Isolate* isolate);
+
+ void Generate(MacroAssembler* masm);
+
+ private:
+ virtual CodeStub::Major MajorKey() { return ArrayConstructor; }
+ virtual int MinorKey() { return argument_count_; }
+
+ ArgumentCountKey argument_count_;
+};
+
+
class MathPowStub: public PlatformCodeStub {
public:
enum ExponentType { INTEGER, DOUBLE, TAGGED, ON_STACK};
@@ -1447,10 +1476,48 @@ class TransitionElementsKindStub : public HydrogenCodeStub {
};
-class ArrayNoArgumentConstructorStub : public HydrogenCodeStub {
+class ArrayConstructorStubBase : public HydrogenCodeStub {
public:
- ArrayNoArgumentConstructorStub()
+ ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {
+ bit_field_ = ElementsKindBits::encode(kind) |
+ AllocationSiteModeBits::encode(mode == TRACK_ALLOCATION_SITE);
+ }
+
+ ElementsKind elements_kind() const {
+ return ElementsKindBits::decode(bit_field_);
+ }
+
+ AllocationSiteMode mode() const {
+ return AllocationSiteModeBits::decode(bit_field_)
+ ? TRACK_ALLOCATION_SITE
+ : DONT_TRACK_ALLOCATION_SITE;
+ }
+
+ virtual bool IsPregenerated() { return true; }
+ static void GenerateStubsAheadOfTime(Isolate* isolate);
+ static void InstallDescriptors(Isolate* isolate);
+
+ // Parameters accessed via CodeStubGraphBuilder::GetParameter()
+ static const int kPropertyCell = 0;
+
+ private:
+ int NotMissMinorKey() { return bit_field_; }
+
+ class ElementsKindBits: public BitField<ElementsKind, 0, 8> {};
+ class AllocationSiteModeBits: public BitField<bool, 8, 1> {};
+ uint32_t bit_field_;
+
+ DISALLOW_COPY_AND_ASSIGN(ArrayConstructorStubBase);
+};
+
+
+class ArrayNoArgumentConstructorStub : public ArrayConstructorStubBase {
+ public:
+ ArrayNoArgumentConstructorStub(
+ ElementsKind kind,
+ AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
+ : ArrayConstructorStubBase(kind, mode) {
}
virtual Handle<Code> GenerateCode();
@@ -1461,16 +1528,18 @@ class ArrayNoArgumentConstructorStub : public HydrogenCodeStub {
private:
Major MajorKey() { return ArrayNoArgumentConstructor; }
- int NotMissMinorKey() { return 0; }
DISALLOW_COPY_AND_ASSIGN(ArrayNoArgumentConstructorStub);
};
-class ArraySingleArgumentConstructorStub : public HydrogenCodeStub {
+class ArraySingleArgumentConstructorStub : public ArrayConstructorStubBase {
public:
- ArraySingleArgumentConstructorStub()
- : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {}
+ ArraySingleArgumentConstructorStub(
+ ElementsKind kind,
+ AllocationSiteMode mode = TRACK_ALLOCATION_SITE)
+ : ArrayConstructorStubBase(kind, mode) {
+ }
virtual Handle<Code> GenerateCode();
@@ -1480,16 +1549,18 @@ class ArraySingleArgumentConstructorStub : public HydrogenCodeStub {
private:
Major MajorKey() { return ArraySingleArgumentConstructor; }
- int NotMissMinorKey() { return 0; }
DISALLOW_COPY_AND_ASSIGN(ArraySingleArgumentConstructorStub);
};
-class ArrayNArgumentsConstructorStub : public HydrogenCodeStub {
+class ArrayNArgumentsConstructorStub : public ArrayConstructorStubBase {
public:
- ArrayNArgumentsConstructorStub()
- : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {}
+ ArrayNArgumentsConstructorStub(
+ ElementsKind kind,
+ AllocationSiteMode mode = TRACK_ALLOCATION_SITE) :
+ ArrayConstructorStubBase(kind, mode) {
+ }
virtual Handle<Code> GenerateCode();
@@ -1499,7 +1570,6 @@ class ArrayNArgumentsConstructorStub : public HydrogenCodeStub {
private:
Major MajorKey() { return ArrayNArgumentsConstructor; }
- int NotMissMinorKey() { return 0; }
DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub);
};
« no previous file with comments | « src/builtins.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698