Revision: 3171
Author: [email protected]
Date: Thu Oct 29 03:35:29 2009
Log: Rename the kinds of locations to be consistent with the (codegen)
context of the expressions they label.  Introduce an "unintialized"
location to catch failure to assign any location at all.

Changed the object literal initialization on ARM to use a Store IC in
the same cases where it did on the other platforms.  This was required
because the location of the literal property name is given an
"unitialized" location.

Review URL: http://codereview.chromium.org/339045
http://code.google.com/p/v8/source/detail?r=3171

Modified:
  /branches/bleeding_edge/src/arm/fast-codegen-arm.cc
  /branches/bleeding_edge/src/ast.h
  /branches/bleeding_edge/src/compiler.cc
  /branches/bleeding_edge/src/fast-codegen.cc
  /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc
  /branches/bleeding_edge/src/location.h
  /branches/bleeding_edge/src/x64/fast-codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Wed Oct 28 06:25:40  
2009
+++ /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Thu Oct 29 03:35:29  
2009
@@ -119,9 +119,11 @@

  void FastCodeGenerator::Move(Location destination, Slot* source) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ ldr(ip, MemOperand(fp, SlotOffset(source)));
        __ push(ip);
        break;
@@ -131,9 +133,11 @@

  void FastCodeGenerator::Move(Location destination, Literal* expr) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ mov(ip, Operand(expr->handle()));
        __ push(ip);
        break;
@@ -143,9 +147,10 @@

  void FastCodeGenerator::Move(Slot* destination, Location source) {
    switch (source.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:  // Fall through.
+    case Location::EFFECT:
        UNREACHABLE();
-    case Location::TEMP:
+    case Location::VALUE:
        __ pop(ip);
        __ str(ip, MemOperand(fp, SlotOffset(destination)));
        break;
@@ -155,10 +160,12 @@

  void FastCodeGenerator::DropAndMove(Location destination, Register source)  
{
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        __ pop();
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ str(source, MemOperand(sp));
        break;
    }
@@ -237,6 +244,33 @@
      Move(expr->location(), rewrite->AsSlot());
    }
  }
+
+
+void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
+  Comment cmnt(masm_, "[ RegExp Literal");
+  Label done;
+  // Registers will be used as follows:
+  // r4 = JS function, literals array
+  // r3 = literal index
+  // r2 = RegExp pattern
+  // r1 = RegExp flags
+  // r0 = temp + return value (RegExp literal)
+  __ ldr(r0, MemOperand(fp,  JavaScriptFrameConstants::kFunctionOffset));
+  __ ldr(r4,  FieldMemOperand(r0, JSFunction::kLiteralsOffset));
+  int literal_offset =
+    FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
+  __ ldr(r0, FieldMemOperand(r4, literal_offset));
+  __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
+  __ cmp(r0, ip);
+  __ b(ne, &done);
+  __ mov(r3, Operand(Smi::FromInt(expr->literal_index())));
+  __ mov(r2, Operand(expr->pattern()));
+  __ mov(r1, Operand(expr->flags()));
+  __ stm(db_w, sp, r4.bit() | r3.bit() | r2.bit() | r1.bit());
+  __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
+  __ bind(&done);
+  Move(expr->location(), r0);
+}


  void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
@@ -284,71 +318,60 @@
        result_saved = true;
      }
      switch (property->kind()) {
-      case ObjectLiteral::Property::MATERIALIZED_LITERAL:   // fall through
+      case ObjectLiteral::Property::CONSTANT:
+        UNREACHABLE();
+
+      case ObjectLiteral::Property::MATERIALIZED_LITERAL:   // Fall  
through.
          ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value()));
-      case ObjectLiteral::Property::COMPUTED:  // fall through
+      case ObjectLiteral::Property::COMPUTED:
+        if (key->handle()->IsSymbol()) {
+          Visit(value);
+          Move(r0, value->location());
+          __ mov(r2, Operand(key->handle()));
+          Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
+          __ Call(ic, RelocInfo::CODE_TARGET);
+          // StoreIC leaves the receiver on the stack.
+          break;
+        }
+        // Fall through.
+
        case ObjectLiteral::Property::PROTOTYPE:
          __ push(r0);
          Visit(key);
-        ASSERT(key->location().is_temporary());
+        ASSERT(key->location().is_value());
          Visit(value);
-        ASSERT(value->location().is_temporary());
+        ASSERT(value->location().is_value());
          __ CallRuntime(Runtime::kSetProperty, 3);
          __ ldr(r0, MemOperand(sp));  // Restore result into r0
          break;
-      case ObjectLiteral::Property::SETTER:  // fall through
-      case ObjectLiteral::Property::GETTER:
+
+      case ObjectLiteral::Property::GETTER:  // Fall through.
+      case ObjectLiteral::Property::SETTER:
          __ push(r0);
          Visit(key);
-        ASSERT(key->location().is_temporary());
+        ASSERT(key->location().is_value());
          __ mov(r1, Operand(property->kind() ==  
ObjectLiteral::Property::SETTER ?
                             Smi::FromInt(1) :
                             Smi::FromInt(0)));
          __ push(r1);
          Visit(value);
-        ASSERT(value->location().is_temporary());
+        ASSERT(value->location().is_value());
          __ CallRuntime(Runtime::kDefineAccessor, 4);
          __ ldr(r0, MemOperand(sp));  // Restore result into r0
          break;
-      default: UNREACHABLE();
      }
    }
    switch (expr->location().type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        if (result_saved) __ pop();
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        if (!result_saved) __ push(r0);
        break;
    }
  }
-
-
-void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
-  Comment cmnt(masm_, "[ RegExp Literal");
-  Label done;
-  // Registers will be used as follows:
-  // r4 = JS function, literals array
-  // r3 = literal index
-  // r2 = RegExp pattern
-  // r1 = RegExp flags
-  // r0 = temp + return value (RegExp literal)
-  __ ldr(r0, MemOperand(fp,  JavaScriptFrameConstants::kFunctionOffset));
-  __ ldr(r4,  FieldMemOperand(r0, JSFunction::kLiteralsOffset));
-  int literal_offset =
-    FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
-  __ ldr(r0, FieldMemOperand(r4, literal_offset));
-  __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
-  __ cmp(r0, ip);
-  __ b(ne, &done);
-  __ mov(r3, Operand(Smi::FromInt(expr->literal_index())));
-  __ mov(r2, Operand(expr->pattern()));
-  __ mov(r1, Operand(expr->flags()));
-  __ stm(db_w, sp, r4.bit() | r3.bit() | r2.bit() | r1.bit());
-  __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
-  __ bind(&done);
-  Move(expr->location(), r0);
-}


  void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
@@ -400,7 +423,7 @@
        result_saved = true;
      }
      Visit(subexpr);
-    ASSERT(subexpr->location().is_temporary());
+    ASSERT(subexpr->location().is_value());

      // Store the subexpression value in the array's elements.
      __ pop(r0);  // Subexpression value.
@@ -416,10 +439,12 @@
    }

    switch (expr->location().type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        if (result_saved) __ pop();
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        if (!result_saved) __ push(r0);
        break;
    }
@@ -446,7 +471,7 @@
      if (rhs->AsLiteral() != NULL) {
        __ mov(r0, Operand(rhs->AsLiteral()->handle()));
      } else {
-      ASSERT(rhs->location().is_temporary());
+      ASSERT(rhs->location().is_value());
        Visit(rhs);
        __ pop(r0);
      }
@@ -468,15 +493,17 @@
        __ str(ip, MemOperand(fp, SlotOffset(var->slot())));
        Move(expr->location(), ip);
      } else {
-      ASSERT(rhs->location().is_temporary());
+      ASSERT(rhs->location().is_value());
        Visit(rhs);
        // Load right-hand side into ip.
        switch (expr->location().type()) {
-        case Location::NOWHERE:
+        case Location::UNINITIALIZED:
+          UNREACHABLE();
+        case Location::EFFECT:
            // Case 'var = temp'.  Discard right-hand-side temporary.
            __ pop(ip);
            break;
-        case Location::TEMP:
+        case Location::VALUE:
            // Case 'temp1 <- (var = temp0)'.  Preserve right-hand-side
            // temporary on the stack.
            __ ldr(ip, MemOperand(sp));
@@ -522,10 +549,12 @@
      __ pop();
    }
    switch (expr->location().type()) {
-    case Location::TEMP:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::VALUE:
        __ str(r0, MemOperand(sp));
        break;
-    case Location::NOWHERE:
+    case Location::EFFECT:
        __ pop();
    }
  }
@@ -546,7 +575,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
    }
    // Record source position for debugger
    SetSourcePosition(expr->position());
@@ -567,7 +596,7 @@
    // arguments.
    // Push function on the stack.
    Visit(node->expression());
-  ASSERT(node->expression()->location().is_temporary());
+  ASSERT(node->expression()->location().is_value());

    // Push global object (receiver).
    __ ldr(r0, CodeGenerator::GlobalObject());
@@ -577,7 +606,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
      // If location is temporary, it is already on the stack,
      // so nothing to do here.
    }
@@ -610,7 +639,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
    }

    __ CallRuntime(function, arg_count);
@@ -636,11 +665,11 @@
    if (left->AsLiteral() != NULL) {
      __ mov(r0, Operand(left->AsLiteral()->handle()));
      __ push(r0);
-    if (destination.is_temporary()) __ push(r0);
+    if (destination.is_value()) __ push(r0);
    } else {
      Visit(left);
-    ASSERT(left->location().is_temporary());
-    if (destination.is_temporary()) {
+    ASSERT(left->location().is_value());
+    if (destination.is_value()) {
        __ ldr(r0, MemOperand(sp));
        __ push(r0);
      }
@@ -653,7 +682,7 @@
    __ b(eq, &done);

    // Discard the left-hand value if present on the stack.
-  if (destination.is_temporary()) __ pop();
+  if (destination.is_value()) __ pop();
    // Save or discard the right-hand value as needed.
    if (right->AsLiteral() != NULL) {
      Move(destination, right->AsLiteral());
=======================================
--- /branches/bleeding_edge/src/ast.h   Wed Oct 28 06:25:40 2009
+++ /branches/bleeding_edge/src/ast.h   Thu Oct 29 03:35:29 2009
@@ -162,7 +162,7 @@

  class Expression: public AstNode {
   public:
-  Expression() : location_(Location::Temporary()) {}
+  Expression() : location_(Location::Uninitialized()) {}

    virtual Expression* AsExpression()  { return this; }

=======================================
--- /branches/bleeding_edge/src/compiler.cc     Wed Oct 28 06:25:40 2009
+++ /branches/bleeding_edge/src/compiler.cc     Thu Oct 29 03:35:29 2009
@@ -48,7 +48,7 @@

    CodeGenSelector()
        : has_supported_syntax_(true),
-        location_(Location::Nowhere()) {
+        location_(Location::Uninitialized()) {
    }

    CodeGenTag Select(FunctionLiteral* fun);
@@ -514,11 +514,11 @@


  void CodeGenSelector::VisitAsEffect(Expression* expr) {
-  if (location_.is_nowhere()) {
+  if (location_.is_effect()) {
      Visit(expr);
    } else {
      Location saved = location_;
-    location_ = Location::Nowhere();
+    location_ = Location::Effect();
      Visit(expr);
      location_ = saved;
    }
@@ -526,11 +526,11 @@


  void CodeGenSelector::VisitAsValue(Expression* expr) {
-  if (location_.is_temporary()) {
+  if (location_.is_value()) {
      Visit(expr);
    } else {
      Location saved = location_;
-    location_ = Location::Temporary();
+    location_ = Location::Value();
      Visit(expr);
      location_ = saved;
    }
=======================================
--- /branches/bleeding_edge/src/fast-codegen.cc Tue Oct 27 09:11:12 2009
+++ /branches/bleeding_edge/src/fast-codegen.cc Thu Oct 29 03:35:29 2009
@@ -73,14 +73,18 @@

  void FastCodeGenerator::Move(Location destination, Location source) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+
+    case Location::EFFECT:
        break;

-    case Location::TEMP:
+    case Location::VALUE:
        switch (source.type()) {
-        case Location::NOWHERE:
+        case Location::UNINITIALIZED:  // Fall through.
+        case Location::EFFECT:
            UNREACHABLE();
-        case Location::TEMP:
+        case Location::VALUE:
            break;
        }
        break;
@@ -92,9 +96,11 @@
  // function.
  void FastCodeGenerator::Move(Location destination, Register source) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        masm_->push(source);
        break;
    }
@@ -105,9 +111,10 @@
  // function.
  void FastCodeGenerator::Move(Register destination, Location source) {
    switch (source.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:  // Fall through.
+    case Location::EFFECT:
        UNREACHABLE();
-    case Location::TEMP:
+    case Location::VALUE:
        masm_->pop(destination);
    }
  }
=======================================
--- /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc       Wed Oct 28  
06:25:40 2009
+++ /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc       Thu Oct 29  
03:35:29 2009
@@ -110,9 +110,11 @@

  void FastCodeGenerator::Move(Location destination, Slot* source) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ push(Operand(ebp, SlotOffset(source)));
        break;
    }
@@ -121,9 +123,11 @@

  void FastCodeGenerator::Move(Location destination, Literal* expr) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ push(Immediate(expr->handle()));
        break;
    }
@@ -132,9 +136,10 @@

  void FastCodeGenerator::Move(Slot* destination, Location source) {
    switch (source.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:  // Fall through.
+    case Location::EFFECT:
        UNREACHABLE();
-    case Location::TEMP:
+    case Location::VALUE:
        __ pop(Operand(ebp, SlotOffset(destination)));
        break;
    }
@@ -143,10 +148,12 @@

  void FastCodeGenerator::DropAndMove(Location destination, Register source)  
{
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        __ add(Operand(esp), Immediate(kPointerSize));
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ mov(Operand(esp, 0), source);
        break;
    }
@@ -229,6 +236,33 @@
      Move(expr->location(), rewrite->AsSlot());
    }
  }
+
+
+void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
+  Comment cmnt(masm_, "[ RegExp Literal");
+  Label done;
+  // Registers will be used as follows:
+  // edi = JS function.
+  // ebx = literals array.
+  // eax = regexp literal.
+  __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
+  __ mov(ebx, FieldOperand(edi, JSFunction::kLiteralsOffset));
+  int literal_offset =
+    FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
+  __ mov(eax, FieldOperand(ebx, literal_offset));
+  __ cmp(eax, Factory::undefined_value());
+  __ j(not_equal, &done);
+  // Create regexp literal using runtime function
+  // Result will be in eax.
+  __ push(ebx);
+  __ push(Immediate(Smi::FromInt(expr->literal_index())));
+  __ push(Immediate(expr->pattern()));
+  __ push(Immediate(expr->flags()));
+  __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
+  // Label done:
+  __ bind(&done);
+  Move(expr->location(), eax);
+}


  void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
@@ -295,9 +329,9 @@
        case ObjectLiteral::Property::PROTOTYPE:
          __ push(eax);
          Visit(key);
-        ASSERT(key->location().is_temporary());
+        ASSERT(key->location().is_value());
          Visit(value);
-        ASSERT(value->location().is_temporary());
+        ASSERT(value->location().is_value());
          __ CallRuntime(Runtime::kSetProperty, 3);
          __ mov(eax, Operand(esp, 0));  // Restore result into eax.
          break;
@@ -305,12 +339,12 @@
        case ObjectLiteral::Property::GETTER:
          __ push(eax);
          Visit(key);
-        ASSERT(key->location().is_temporary());
+        ASSERT(key->location().is_value());
          __ push(Immediate(property->kind() ==  
ObjectLiteral::Property::SETTER ?
                            Smi::FromInt(1) :
                            Smi::FromInt(0)));
          Visit(value);
-        ASSERT(value->location().is_temporary());
+        ASSERT(value->location().is_value());
          __ CallRuntime(Runtime::kDefineAccessor, 4);
          __ mov(eax, Operand(esp, 0));  // Restore result into eax.
          break;
@@ -318,41 +352,16 @@
      }
    }
    switch (expr->location().type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        if (result_saved) __ add(Operand(esp), Immediate(kPointerSize));
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        if (!result_saved) __ push(eax);
        break;
    }
  }
-
-
-void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
-  Comment cmnt(masm_, "[ RegExp Literal");
-  Label done;
-  // Registers will be used as follows:
-  // edi = JS function.
-  // ebx = literals array.
-  // eax = regexp literal.
-  __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
-  __ mov(ebx, FieldOperand(edi, JSFunction::kLiteralsOffset));
-  int literal_offset =
-    FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
-  __ mov(eax, FieldOperand(ebx, literal_offset));
-  __ cmp(eax, Factory::undefined_value());
-  __ j(not_equal, &done);
-  // Create regexp literal using runtime function
-  // Result will be in eax.
-  __ push(ebx);
-  __ push(Immediate(Smi::FromInt(expr->literal_index())));
-  __ push(Immediate(expr->pattern()));
-  __ push(Immediate(expr->flags()));
-  __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
-  // Label done:
-  __ bind(&done);
-  Move(expr->location(), eax);
-}


  void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
@@ -403,7 +412,7 @@
        result_saved = true;
      }
      Visit(subexpr);
-    ASSERT(subexpr->location().is_temporary());
+    ASSERT(subexpr->location().is_value());

      // Store the subexpression value in the array's elements.
      __ pop(eax);  // Subexpression value.
@@ -417,10 +426,12 @@
    }

    switch (expr->location().type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        if (result_saved) __ add(Operand(esp), Immediate(kPointerSize));
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        if (!result_saved) __ push(eax);
        break;
    }
@@ -446,7 +457,7 @@
      if (rhs->AsLiteral() != NULL) {
        __ mov(eax, rhs->AsLiteral()->handle());
      } else {
-      ASSERT(rhs->location().is_temporary());
+      ASSERT(rhs->location().is_value());
        Visit(rhs);
        __ pop(eax);
      }
@@ -467,14 +478,16 @@
        __ mov(Operand(ebp, SlotOffset(var->slot())), eax);
        Move(expr->location(), eax);
      } else {
-      ASSERT(rhs->location().is_temporary());
+      ASSERT(rhs->location().is_value());
        Visit(rhs);
        switch (expr->location().type()) {
-        case Location::NOWHERE:
+        case Location::UNINITIALIZED:
+          UNREACHABLE();
+        case Location::EFFECT:
            // Case 'var = temp'.  Discard right-hand-side temporary.
            Move(var->slot(), rhs->location());
            break;
-        case Location::TEMP:
+        case Location::VALUE:
            // Case 'temp1 <- (var = temp0)'.  Preserve right-hand-side
            // temporary on the stack.
            __ mov(eax, Operand(esp, 0));
@@ -519,10 +532,12 @@
      __ add(Operand(esp), Immediate(kPointerSize));
    }
    switch (expr->location().type()) {
-    case Location::TEMP:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::VALUE:
        __ mov(Operand(esp, 0), eax);
        break;
-    case Location::NOWHERE:
+    case Location::EFFECT:
        __ add(Operand(esp), Immediate(kPointerSize));
        break;
    }
@@ -542,7 +557,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
    }
    // Record source position for debugger
    SetSourcePosition(expr->position());
@@ -564,7 +579,7 @@
    // arguments.
    // Push function on the stack.
    Visit(node->expression());
-  ASSERT(node->expression()->location().is_temporary());
+  ASSERT(node->expression()->location().is_value());

    // Push global object (receiver).
    __ push(CodeGenerator::GlobalObject());
@@ -574,7 +589,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
      // If location is temporary, it is already on the stack,
      // so nothing to do here.
    }
@@ -607,7 +622,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
    }

    __ CallRuntime(function, arg_count);
@@ -635,17 +650,19 @@
    // need it as the value of the whole expression.
    if (left->AsLiteral() != NULL) {
      __ mov(eax, left->AsLiteral()->handle());
-    if (destination.is_temporary()) __ push(eax);
+    if (destination.is_value()) __ push(eax);
    } else {
      Visit(left);
-    ASSERT(left->location().is_temporary());
+    ASSERT(left->location().is_value());
      switch (destination.type()) {
-      case Location::NOWHERE:
+      case Location::UNINITIALIZED:
+        UNREACHABLE();
+      case Location::EFFECT:
          // Pop the left-hand value into eax because we will not need it as  
the
          // final result.
          __ pop(eax);
          break;
-      case Location::TEMP:
+      case Location::VALUE:
          // Copy the left-hand value into eax because we may need it as the
          // final result.
          __ mov(eax, Operand(esp, 0));
@@ -677,7 +694,7 @@

    __ bind(&eval_right);
    // Discard the left-hand value if present on the stack.
-  if (destination.is_temporary()) {
+  if (destination.is_value()) {
      __ add(Operand(esp), Immediate(kPointerSize));
    }
    // Save or discard the right-hand value as needed.
=======================================
--- /branches/bleeding_edge/src/location.h      Tue Oct 27 06:38:57 2009
+++ /branches/bleeding_edge/src/location.h      Thu Oct 29 03:35:29 2009
@@ -35,13 +35,14 @@

  class Location BASE_EMBEDDED {
   public:
-  enum Type { NOWHERE, TEMP };
-
-  static Location Temporary() { return Location(TEMP); }
-  static Location Nowhere() { return Location(NOWHERE); }
-
-  bool is_temporary() { return type_ == TEMP; }
-  bool is_nowhere() { return type_ == NOWHERE; }
+  enum Type { UNINITIALIZED, EFFECT, VALUE };
+
+  static Location Uninitialized() { return Location(UNINITIALIZED); }
+  static Location Effect() { return Location(EFFECT); }
+  static Location Value() { return Location(VALUE); }
+
+  bool is_effect() { return type_ == EFFECT; }
+  bool is_value() { return type_ == VALUE; }

    Type type() { return type_; }

=======================================
--- /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Wed Oct 28 06:25:40  
2009
+++ /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Thu Oct 29 03:35:29  
2009
@@ -118,9 +118,11 @@

  void FastCodeGenerator::Move(Location destination, Slot* source) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ push(Operand(rbp, SlotOffset(source)));
        break;
    }
@@ -129,9 +131,11 @@

  void FastCodeGenerator::Move(Location destination, Literal* expr) {
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ Push(expr->handle());
        break;
    }
@@ -140,9 +144,10 @@

  void FastCodeGenerator::Move(Slot* destination, Location source) {
    switch (source.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:  // Fall through.
+    case Location::EFFECT:
        UNREACHABLE();
-    case Location::TEMP:
+    case Location::VALUE:
        __ pop(Operand(rbp, SlotOffset(destination)));
        break;
    }
@@ -151,10 +156,12 @@

  void FastCodeGenerator::DropAndMove(Location destination, Register source)  
{
    switch (destination.type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        __ addq(rsp, Immediate(kPointerSize));
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        __ movq(Operand(rsp, 0), source);
        break;
    }
@@ -244,6 +251,33 @@
      Move(expr->location(), rewrite->AsSlot());
    }
  }
+
+
+void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
+  Comment cmnt(masm_, "[ RegExp Literal");
+  Label done;
+  // Registers will be used as follows:
+  // rdi = JS function.
+  // rbx = literals array.
+  // rax = regexp literal.
+  __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
+  __ movq(rbx, FieldOperand(rdi, JSFunction::kLiteralsOffset));
+  int literal_offset =
+    FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
+  __ movq(rax, FieldOperand(rbx, literal_offset));
+  __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
+  __ j(not_equal, &done);
+  // Create regexp literal using runtime function
+  // Result will be in rax.
+  __ push(rbx);
+  __ Push(Smi::FromInt(expr->literal_index()));
+  __ Push(expr->pattern());
+  __ Push(expr->flags());
+  __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
+  // Label done:
+  __ bind(&done);
+  Move(expr->location(), rax);
+}


  void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
@@ -295,7 +329,7 @@
        case ObjectLiteral::Property::COMPUTED:
          if (key->handle()->IsSymbol()) {
            Visit(value);
-          ASSERT(value->location().is_temporary());
+          ASSERT(value->location().is_value());
            __ pop(rax);
            __ Move(rcx, key->handle());
            Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
@@ -307,9 +341,9 @@
        case ObjectLiteral::Property::PROTOTYPE:
          __ push(rax);
          Visit(key);
-        ASSERT(key->location().is_temporary());
+        ASSERT(key->location().is_value());
          Visit(value);
-        ASSERT(value->location().is_temporary());
+        ASSERT(value->location().is_value());
          __ CallRuntime(Runtime::kSetProperty, 3);
          __ movq(rax, Operand(rsp, 0));  // Restore result into rax.
          break;
@@ -317,12 +351,12 @@
        case ObjectLiteral::Property::GETTER:
          __ push(rax);
          Visit(key);
-        ASSERT(key->location().is_temporary());
+        ASSERT(key->location().is_value());
          __ Push(property->kind() == ObjectLiteral::Property::SETTER ?
                  Smi::FromInt(1) :
                  Smi::FromInt(0));
          Visit(value);
-        ASSERT(value->location().is_temporary());
+        ASSERT(value->location().is_value());
          __ CallRuntime(Runtime::kDefineAccessor, 4);
          __ movq(rax, Operand(rsp, 0));  // Restore result into rax.
          break;
@@ -330,41 +364,16 @@
      }
    }
    switch (expr->location().type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        if (result_saved) __ addq(rsp, Immediate(kPointerSize));
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        if (!result_saved) __ push(rax);
        break;
    }
  }
-
-
-void FastCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
-  Comment cmnt(masm_, "[ RegExp Literal");
-  Label done;
-  // Registers will be used as follows:
-  // rdi = JS function.
-  // rbx = literals array.
-  // rax = regexp literal.
-  __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
-  __ movq(rbx, FieldOperand(rdi, JSFunction::kLiteralsOffset));
-  int literal_offset =
-    FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
-  __ movq(rax, FieldOperand(rbx, literal_offset));
-  __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
-  __ j(not_equal, &done);
-  // Create regexp literal using runtime function
-  // Result will be in rax.
-  __ push(rbx);
-  __ Push(Smi::FromInt(expr->literal_index()));
-  __ Push(expr->pattern());
-  __ Push(expr->flags());
-  __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
-  // Label done:
-  __ bind(&done);
-  Move(expr->location(), rax);
-}


  void FastCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
@@ -415,7 +424,7 @@
        result_saved = true;
      }
      Visit(subexpr);
-    ASSERT(subexpr->location().is_temporary());
+    ASSERT(subexpr->location().is_value());

      // Store the subexpression value in the array's elements.
      __ pop(rax);  // Subexpression value.
@@ -429,10 +438,12 @@
    }

    switch (expr->location().type()) {
-    case Location::NOWHERE:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::EFFECT:
        if (result_saved) __ addq(rsp, Immediate(kPointerSize));
        break;
-    case Location::TEMP:
+    case Location::VALUE:
        if (!result_saved) __ push(rax);
        break;
    }
@@ -459,7 +470,7 @@
      if (rhs->AsLiteral() != NULL) {
        __ Move(rax, rhs->AsLiteral()->handle());
      } else {
-      ASSERT(rhs->location().is_temporary());
+      ASSERT(rhs->location().is_value());
        Visit(rhs);
        __ pop(rax);
      }
@@ -480,14 +491,16 @@
        __ movq(Operand(rbp, SlotOffset(var->slot())), kScratchRegister);
        Move(expr->location(), kScratchRegister);
      } else {
-      ASSERT(rhs->location().is_temporary());
+      ASSERT(rhs->location().is_value());
        Visit(rhs);
        switch (expr->location().type()) {
-        case Location::NOWHERE:
+        case Location::UNINITIALIZED:
+          UNREACHABLE();
+        case Location::EFFECT:
            // Case 'var = temp'.  Discard right-hand-side temporary.
            Move(var->slot(), rhs->location());
            break;
-        case Location::TEMP:
+        case Location::VALUE:
            // Case 'temp1 <- (var = temp0)'.  Preserve right-hand-side
            // temporary on the stack.
            __ movq(kScratchRegister, Operand(rsp, 0));
@@ -532,10 +545,12 @@
      __ addq(rsp, Immediate(kPointerSize));
    }
    switch (expr->location().type()) {
-    case Location::TEMP:
+    case Location::UNINITIALIZED:
+      UNREACHABLE();
+    case Location::VALUE:
        __ movq(Operand(rsp, 0), rax);
        break;
-    case Location::NOWHERE:
+    case Location::EFFECT:
        __ addq(rsp, Immediate(kPointerSize));
        break;
    }
@@ -555,7 +570,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
    }
    // Record source position for debugger
    SetSourcePosition(expr->position());
@@ -577,7 +592,7 @@
    // arguments.
    // Push function on the stack.
    Visit(node->expression());
-  ASSERT(node->expression()->location().is_temporary());
+  ASSERT(node->expression()->location().is_value());
    // If location is temporary, already on the stack,

    // Push global object (receiver).
@@ -588,7 +603,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
      // If location is temporary, it is already on the stack,
      // so nothing to do here.
    }
@@ -621,7 +636,7 @@
    int arg_count = args->length();
    for (int i = 0; i < arg_count; i++) {
      Visit(args->at(i));
-    ASSERT(args->at(i)->location().is_temporary());
+    ASSERT(args->at(i)->location().is_value());
    }

    __ CallRuntime(function, arg_count);
@@ -649,17 +664,19 @@
    // need it as the value of the whole expression.
    if (left->AsLiteral() != NULL) {
      __ Move(rax, left->AsLiteral()->handle());
-    if (destination.is_temporary()) __ push(rax);
+    if (destination.is_value()) __ push(rax);
    } else {
      Visit(left);
-    ASSERT(left->location().is_temporary());
+    ASSERT(left->location().is_value());
      switch (destination.type()) {
-      case Location::NOWHERE:
+      case Location::UNINITIALIZED:
+        UNREACHABLE();
+      case Location::EFFECT:
          // Pop the left-hand value into rax because we will not need it as  
the
          // final result.
          __ pop(rax);
          break;
-      case Location::TEMP:
+      case Location::VALUE:
          // Copy the left-hand value into rax because we may need it as the
          // final result.
          __ movq(rax, Operand(rsp, 0));
@@ -692,7 +709,7 @@

    __ bind(&eval_right);
    // Discard the left-hand value if present on the stack.
-  if (destination.is_temporary()) {
+  if (destination.is_value()) {
      __ addq(rsp, Immediate(kPointerSize));
    }
    // Save or discard the right-hand value as needed.

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to