Reviewers: Benedikt Meurer,

Message:
Hi Benedikt, here is a refactoring that moves us closer to determining the
number of type cells required at parse rather than compile time. PTAL, thx!
--Michael

Description:
Moving logic to AstNode to determine how many type cells are required.

With this change, we'll be able to discover how many type cells we
need at parse time, enabling future optimizations.

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

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

Affected files (+36, -6 lines):
  M src/ast.h
  M src/ast.cc
  M src/ia32/full-codegen-ia32.cc


Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index da86a1162d7bc726ab7c4ec5f8f94ff11ca7f26d..3ffa97244af9e4f8703dae780f8fc718cb44da5b 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -595,6 +595,29 @@ void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
   to_boolean_types_ = oracle->ToBooleanTypes(test_id());
 }

+bool Call::ProxyIsPossiblyEval(Isolate* isolate) const {
+  VariableProxy* proxy = expression()->AsVariableProxy();
+  return proxy != NULL && proxy->var()->is_possibly_eval(isolate);
+}
+
+
+bool Call::ProxyIsUnallocated() const {
+  VariableProxy* proxy = expression()->AsVariableProxy();
+  return proxy != NULL && proxy->var()->IsUnallocated();
+}
+
+
+bool Call::ProxyIsLookupSlot() const {
+  VariableProxy* proxy = expression()->AsVariableProxy();
+  return proxy != NULL && proxy->var()->IsLookupSlot();
+}
+
+
+bool Call::IsMemberOrKeyedCall() const {
+  Property* property = expression()->AsProperty();
+  return property != NULL;
+}
+

 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) {
// If there is an interceptor, we can't compute the target for a direct call.
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 23f72df2ea87efee2cb00126e687bc682f677522..b63b5420858001f4c9d8df13f7bb8aababc8c936 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -1774,6 +1774,12 @@ class Call V8_FINAL : public Expression {

   BailoutId ReturnId() const { return return_id_; }

+  // Helpers to determine how to handle the call.
+  bool ProxyIsPossiblyEval(Isolate* isolate) const;
+  bool ProxyIsUnallocated() const;
+  bool ProxyIsLookupSlot() const;
+  bool IsMemberOrKeyedCall() const;
+
// TODO(rossberg): this should really move somewhere else (and be merged with
   // various similar methods in objets.cc), but for now...
   static Handle<JSObject> GetPrototypeForPrimitiveCheck(
Index: src/ia32/full-codegen-ia32.cc
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 14e3df61d10a867966d0f69c945263a4fb8f73bb..78bc14bdf2684bbf1f5afa1eaa624fca155848f8 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -2673,10 +2673,8 @@ void FullCodeGenerator::VisitCall(Call* expr) {

   Comment cmnt(masm_, "[ Call");
   Expression* callee = expr->expression();
-  VariableProxy* proxy = callee->AsVariableProxy();
-  Property* property = callee->AsProperty();

-  if (proxy != NULL && proxy->var()->is_possibly_eval(isolate())) {
+  if (expr->ProxyIsPossiblyEval(isolate())) {
     // In a call to eval, we first call %ResolvePossiblyDirectEval to
     // resolve the function we need to call and the receiver of the call.
     // Then we call the resolved function using the given arguments.
@@ -2711,12 +2709,14 @@ void FullCodeGenerator::VisitCall(Call* expr) {
     __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
     context()->DropAndPlug(1, eax);

-  } else if (proxy != NULL && proxy->var()->IsUnallocated()) {
+  } else if (expr->ProxyIsUnallocated()) {
     // Push global object as receiver for the call IC.
     __ push(GlobalObjectOperand());
+    VariableProxy* proxy = callee->AsVariableProxy();
     EmitCallWithIC(expr, proxy->name(), CONTEXTUAL);
-  } else if (proxy != NULL && proxy->var()->IsLookupSlot()) {
+  } else if (expr->ProxyIsLookupSlot()) {
     // Call to a lookup slot (dynamically introduced variable).
+    VariableProxy* proxy = callee->AsVariableProxy();
     Label slow, done;
     { PreservePositionScope scope(masm()->positions_recorder());
       // Generate code for loading from variables potentially shadowed by
@@ -2750,7 +2750,8 @@ void FullCodeGenerator::VisitCall(Call* expr) {
     // LoadContextSlot.
     EmitCallWithStub(expr);

-  } else if (property != NULL) {
+  } else if (expr->IsMemberOrKeyedCall()) {
+    Property* property = callee->AsProperty();
     { PreservePositionScope scope(masm()->positions_recorder());
       VisitForStackValue(property->obj());
     }


--
--
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/groups/opt_out.

Reply via email to