Chromium Code Reviews| Index: src/code-stubs-hydrogen.cc |
| diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc |
| index dbe41cbf5482719be369f92f136f23b094db44a0..ad161c2129e0d15da154bf08c6211f3c629b5f81 100644 |
| --- a/src/code-stubs-hydrogen.cc |
| +++ b/src/code-stubs-hydrogen.cc |
| @@ -82,6 +82,24 @@ class CodeStubGraphBuilderBase : public HGraphBuilder { |
| HContext* context() { return context_; } |
| Isolate* isolate() { return info_.isolate(); } |
| + class ArrayContextChecker { |
| + public: |
| + ArrayContextChecker(HGraphBuilder* builder, HValue* constructor, |
| + HValue* array_function) |
| + : checker_(builder) { |
| + checker_.If<HCompareObjectEqAndBranch, HValue*>(constructor, |
| + array_function); |
| + checker_.Then(); |
| + } |
| + |
| + ~ArrayContextChecker() { |
| + checker_.ElseDeopt(); |
| + checker_.End(); |
| + } |
| + private: |
| + IfBuilder checker_; |
| + }; |
| + |
| private: |
| SmartArrayPointer<HParameter*> parameters_; |
| HValue* arguments_length_; |
| @@ -524,6 +542,11 @@ HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { |
| // -- Parameter 1 : type info cell |
| // -- Parameter 0 : constructor |
| // ----------------------------------- |
| + HValue* array_result = GetParameter(0); |
|
Toon Verwaest
2013/05/07 11:02:06
Remove
mvstanton
2013/05/07 12:40:50
Done.
|
| + HInstruction* array_function = BuildGetArrayFunction(context()); |
| + ArrayContextChecker(this, |
| + GetParameter(ArrayConstructorStubBase::kConstructor), |
| + array_function); |
| // Get the right map |
| // Should be a constant |
| JSArrayBuilder array_builder( |
| @@ -531,7 +554,8 @@ HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() { |
| casted_stub()->elements_kind(), |
| GetParameter(ArrayConstructorStubBase::kPropertyCell), |
| casted_stub()->mode()); |
| - return array_builder.AllocateEmptyArray(); |
| + array_result = array_builder.AllocateEmptyArray(); |
|
Toon Verwaest
2013/05/07 11:02:06
Just return.
mvstanton
2013/05/07 12:40:50
Done.
|
| + return array_result; |
| } |
| @@ -543,6 +567,10 @@ Handle<Code> ArrayNoArgumentConstructorStub::GenerateCode() { |
| template <> |
| HValue* CodeStubGraphBuilder<ArraySingleArgumentConstructorStub>:: |
| BuildCodeStub() { |
| + HInstruction* array_function = BuildGetArrayFunction(context()); |
| + ArrayContextChecker(this, |
| + GetParameter(ArrayConstructorStubBase::kConstructor), |
| + array_function); |
| // Smi check and range check on the input arg. |
| HValue* constant_one = graph()->GetConstant1(); |
| HValue* constant_zero = graph()->GetConstant0(); |
| @@ -596,6 +624,10 @@ Handle<Code> ArraySingleArgumentConstructorStub::GenerateCode() { |
| template <> |
| HValue* CodeStubGraphBuilder<ArrayNArgumentsConstructorStub>::BuildCodeStub() { |
| + HInstruction* array_function = BuildGetArrayFunction(context()); |
| + ArrayContextChecker(this, |
| + GetParameter(ArrayConstructorStubBase::kConstructor), |
| + array_function); |
| ElementsKind kind = casted_stub()->elements_kind(); |
| HValue* length = GetArgumentsLength(); |