Reviewers: titzer,

Message:
Committed patchset #1 manually as 22905 (presubmit successful).

Description:
Carry along ContextualMode in JSLoadNamed operators.

[email protected]

Committed: https://code.google.com/p/v8/source/detail?r=22905

Please review this at https://codereview.chromium.org/435393004/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+16, -23 lines):
  M src/compiler/ast-graph-builder.cc
  M src/compiler/js-generic-lowering.cc
  M src/compiler/js-operator.h
  M src/compiler/js-typed-lowering.h


Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 3ae5aa4079d78dee54465565f1da2bd2fbf09c64..383ac93924fc61ab41003b51dd2635bbfc1a52e6 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1685,21 +1685,9 @@ Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
   switch (variable->location()) {
     case Variable::UNALLOCATED: {
       // Global var, const, or let variable.
-      if (!info()->is_native()) {
- // TODO(turbofan): This special case is needed only because we don't
-        // use LoadICs yet. Remove this once LoadNamed is lowered to an IC.
-        Node* name = jsgraph()->Constant(variable->name());
-        Runtime::FunctionId function_id =
-            (contextual_mode == CONTEXTUAL)
-                ? Runtime::kLoadLookupSlot
-                : Runtime::kLoadLookupSlotNoReferenceError;
-        Operator* op = javascript()->Runtime(function_id, 2);
-        Node* pair = NewNode(op, current_context(), name);
-        return NewNode(common()->Projection(0), pair);
-      }
       Node* global = BuildLoadGlobalObject();
       PrintableUnique<Name> name = MakeUnique(variable->name());
-      Operator* op = javascript()->LoadNamed(name);
+      Operator* op = javascript()->LoadNamed(name, contextual_mode);
       return NewNode(op, global);
     }
     case Variable::PARAMETER:
Index: src/compiler/js-generic-lowering.cc
diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index 8b230c928f498ac851327dce4bfe9e962204448d..043722f9cc01cd61893b2ea087fcbd9432d2a2dd 100644
--- a/src/compiler/js-generic-lowering.cc
+++ b/src/compiler/js-generic-lowering.cc
@@ -429,11 +429,9 @@ Node* JSGenericLowering::LowerJSLoadProperty(Node* node) {


 Node* JSGenericLowering::LowerJSLoadNamed(Node* node) {
-  PrintableUnique<Name> key = OpParameter<PrintableUnique<Name> >(node);
-  // TODO(mstarzinger): The ContextualMode needs to be carried along in the
-  // operator to use JSLoadNamed for global variable loads.
-  LoadICStubShim stub(isolate(), NOT_CONTEXTUAL);
-  PatchInsertInput(node, 1, jsgraph()->HeapConstant(key));
+  LoadNamedParameters p = OpParameter<LoadNamedParameters>(node);
+  LoadICStubShim stub(isolate(), p.contextual_mode);
+  PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name));
   ReplaceWithICStubCall(node, &stub);
   return node;
 }
Index: src/compiler/js-operator.h
diff --git a/src/compiler/js-operator.h b/src/compiler/js-operator.h
index 6cd4ce1d0e2fb8aabc79abf298bd5397b9507b36..d32eb5a39108b7ead2b7224be6c0d241cc42a432 100644
--- a/src/compiler/js-operator.h
+++ b/src/compiler/js-operator.h
@@ -36,6 +36,13 @@ class ContextAccess {
   const uint32_t index_;
 };

+// Defines the property being loaded from an object by a named load. This is
+// used as a parameter by JSLoadNamed operators.
+struct LoadNamedParameters {
+  PrintableUnique<Name> name;
+  ContextualMode contextual_mode;
+};
+
// Defines the arity and the call flags for a JavaScript function call. This is
 // used as a parameter by JSCall operators.
 struct CallParameters {
@@ -109,9 +116,11 @@ class JSOperatorBuilder {
   }

   Operator* LoadProperty() { BINOP(JSLoadProperty); }
-  Operator* LoadNamed(PrintableUnique<Name> name) {
- OP1(JSLoadNamed, PrintableUnique<Name>, name, Operator::kNoProperties, 1,
-        1);
+  Operator* LoadNamed(PrintableUnique<Name> name,
+                      ContextualMode contextual_mode = NOT_CONTEXTUAL) {
+    LoadNamedParameters parameters = {name, contextual_mode};
+ OP1(JSLoadNamed, LoadNamedParameters, parameters, Operator::kNoProperties,
+        1, 1);
   }

   Operator* StoreProperty() { NOPROPS(JSStoreProperty, 3, 0); }
Index: src/compiler/js-typed-lowering.h
diff --git a/src/compiler/js-typed-lowering.h b/src/compiler/js-typed-lowering.h index 184058b12ed83933495f539ebdbce43abc2fe0a3..c69fc2736a1be87375e23532fd173b73b59d23eb 100644
--- a/src/compiler/js-typed-lowering.h
+++ b/src/compiler/js-typed-lowering.h
@@ -16,8 +16,6 @@ namespace v8 {
 namespace internal {
 namespace compiler {

-class JSBinopReduction;
-
 // Lowers JS-level operators to simplified operators based on types.
 class JSTypedLowering : public LoweringBuilder {
  public:


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to