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

Unified Diff: src/code-stubs-hydrogen.cc

Issue 14846017: Becuase of cross-context calls, hydrogen-based Array constructor needs to ensure (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Enable optimize_constructed_arrays Created 7 years, 7 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/code-stubs.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index dbe41cbf5482719be369f92f136f23b094db44a0..fba1aeb89d99c8ea04d5b6a74f63ef88b100291c 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,10 @@ HValue* CodeStubGraphBuilder<ArrayNoArgumentConstructorStub>::BuildCodeStub() {
// -- Parameter 1 : type info cell
// -- Parameter 0 : constructor
// -----------------------------------
+ HInstruction* array_function = BuildGetArrayFunction(context());
+ ArrayContextChecker(this,
+ GetParameter(ArrayConstructorStubBase::kConstructor),
+ array_function);
// Get the right map
// Should be a constant
JSArrayBuilder array_builder(
@@ -543,6 +565,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 +622,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();
« no previous file with comments | « src/code-stubs.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698