Revision: 3175
Author: [email protected]
Date: Thu Oct 29 06:58:04 2009
Log: Rename the Location type tags to be consistent with our current naming
scheme for enumerations (eg, EFFECT => kEffect).

Remove the ability to move from one Location to another, which should
never be necessary.

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

Modified:
  /branches/bleeding_edge/src/arm/fast-codegen-arm.cc
  /branches/bleeding_edge/src/fast-codegen.cc
  /branches/bleeding_edge/src/fast-codegen.h
  /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 Thu Oct 29 04:55:03  
2009
+++ /branches/bleeding_edge/src/arm/fast-codegen-arm.cc Thu Oct 29 06:58:04  
2009
@@ -119,11 +119,11 @@

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

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

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

  void FastCodeGenerator::DropAndMove(Location destination, Register source)  
{
    switch (destination.type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        __ pop();
        break;
-    case Location::VALUE:
+    case Location::kValue:
        __ str(source, MemOperand(sp));
        break;
    }
@@ -362,12 +362,12 @@
      }
    }
    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        if (result_saved) __ pop();
        break;
-    case Location::VALUE:
+    case Location::kValue:
        if (!result_saved) __ push(r0);
        break;
    }
@@ -439,12 +439,12 @@
    }

    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        if (result_saved) __ pop();
        break;
-    case Location::VALUE:
+    case Location::kValue:
        if (!result_saved) __ push(r0);
        break;
    }
@@ -497,13 +497,13 @@
        Visit(rhs);
        // Load right-hand side into ip.
        switch (expr->location().type()) {
-        case Location::UNINITIALIZED:
+        case Location::kUninitialized:
            UNREACHABLE();
-        case Location::EFFECT:
+        case Location::kEffect:
            // Case 'var = temp'.  Discard right-hand-side temporary.
            __ pop(ip);
            break;
-        case Location::VALUE:
+        case Location::kValue:
            // Case 'temp1 <- (var = temp0)'.  Preserve right-hand-side
            // temporary on the stack.
            __ ldr(ip, MemOperand(sp));
@@ -549,12 +549,12 @@
      __ pop();
    }
    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::VALUE:
+    case Location::kValue:
        __ str(r0, MemOperand(sp));
        break;
-    case Location::EFFECT:
+    case Location::kEffect:
        __ pop();
    }
  }
@@ -734,12 +734,8 @@
    // Discard the left-hand value if present on the stack.
    if (destination.is_value()) __ pop();
    // Save or discard the right-hand value as needed.
-  if (right->AsLiteral() != NULL) {
-    Move(destination, right->AsLiteral());
-  } else {
-    Visit(right);
-    Move(destination, right->location());
-  }
+  Visit(right);
+  ASSERT_EQ(destination.type(), right->location().type());

    __ bind(&done);
  }
=======================================
--- /branches/bleeding_edge/src/fast-codegen.cc Thu Oct 29 03:35:29 2009
+++ /branches/bleeding_edge/src/fast-codegen.cc Thu Oct 29 06:58:04 2009
@@ -69,38 +69,17 @@
    }
    return offset;
  }
-
-
-void FastCodeGenerator::Move(Location destination, Location source) {
-  switch (destination.type()) {
-    case Location::UNINITIALIZED:
-      UNREACHABLE();
-
-    case Location::EFFECT:
-      break;
-
-    case Location::VALUE:
-      switch (source.type()) {
-        case Location::UNINITIALIZED:  // Fall through.
-        case Location::EFFECT:
-          UNREACHABLE();
-        case Location::VALUE:
-          break;
-      }
-      break;
-  }
-}


  // All platform macro assemblers in {ia32,x64,arm} have a push(Register)
  // function.
  void FastCodeGenerator::Move(Location destination, Register source) {
    switch (destination.type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        break;
-    case Location::VALUE:
+    case Location::kValue:
        masm_->push(source);
        break;
    }
@@ -111,10 +90,10 @@
  // function.
  void FastCodeGenerator::Move(Register destination, Location source) {
    switch (source.type()) {
-    case Location::UNINITIALIZED:  // Fall through.
-    case Location::EFFECT:
+    case Location::kUninitialized:  // Fall through.
+    case Location::kEffect:
        UNREACHABLE();
-    case Location::VALUE:
+    case Location::kValue:
        masm_->pop(destination);
    }
  }
=======================================
--- /branches/bleeding_edge/src/fast-codegen.h  Thu Oct 29 04:55:03 2009
+++ /branches/bleeding_edge/src/fast-codegen.h  Thu Oct 29 06:58:04 2009
@@ -51,8 +51,6 @@
   private:
    int SlotOffset(Slot* slot);

-  void Move(Location destination, Location source);
-
    void Move(Location destination, Register source);
    void Move(Location destination, Slot* source);
    void Move(Location destination, Literal* source);
=======================================
--- /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc       Thu Oct 29  
04:55:03 2009
+++ /branches/bleeding_edge/src/ia32/fast-codegen-ia32.cc       Thu Oct 29  
06:58:04 2009
@@ -110,11 +110,11 @@

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

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

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

  void FastCodeGenerator::DropAndMove(Location destination, Register source)  
{
    switch (destination.type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        __ add(Operand(esp), Immediate(kPointerSize));
        break;
-    case Location::VALUE:
+    case Location::kValue:
        __ mov(Operand(esp, 0), source);
        break;
    }
@@ -352,12 +352,12 @@
      }
    }
    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        if (result_saved) __ add(Operand(esp), Immediate(kPointerSize));
        break;
-    case Location::VALUE:
+    case Location::kValue:
        if (!result_saved) __ push(eax);
        break;
    }
@@ -426,12 +426,12 @@
    }

    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        if (result_saved) __ add(Operand(esp), Immediate(kPointerSize));
        break;
-    case Location::VALUE:
+    case Location::kValue:
        if (!result_saved) __ push(eax);
        break;
    }
@@ -481,13 +481,13 @@
        ASSERT(rhs->location().is_value());
        Visit(rhs);
        switch (expr->location().type()) {
-        case Location::UNINITIALIZED:
+        case Location::kUninitialized:
            UNREACHABLE();
-        case Location::EFFECT:
+        case Location::kEffect:
            // Case 'var = temp'.  Discard right-hand-side temporary.
            Move(var->slot(), rhs->location());
            break;
-        case Location::VALUE:
+        case Location::kValue:
            // Case 'temp1 <- (var = temp0)'.  Preserve right-hand-side
            // temporary on the stack.
            __ mov(eax, Operand(esp, 0));
@@ -532,12 +532,12 @@
      __ add(Operand(esp), Immediate(kPointerSize));
    }
    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::VALUE:
+    case Location::kValue:
        __ mov(Operand(esp, 0), eax);
        break;
-    case Location::EFFECT:
+    case Location::kEffect:
        __ add(Operand(esp), Immediate(kPointerSize));
        break;
    }
@@ -706,14 +706,14 @@
      Visit(left);
      ASSERT(left->location().is_value());
      switch (destination.type()) {
-      case Location::UNINITIALIZED:
+      case Location::kUninitialized:
          UNREACHABLE();
-      case Location::EFFECT:
+      case Location::kEffect:
          // Pop the left-hand value into eax because we will not need it as  
the
          // final result.
          __ pop(eax);
          break;
-      case Location::VALUE:
+      case Location::kValue:
          // Copy the left-hand value into eax because we may need it as the
          // final result.
          __ mov(eax, Operand(esp, 0));
@@ -753,12 +753,8 @@
      __ add(Operand(esp), Immediate(kPointerSize));
    }
    // Save or discard the right-hand value as needed.
-  if (right->AsLiteral() != NULL) {
-    Move(destination, right->AsLiteral());
-  } else {
-    Visit(right);
-    Move(destination, right->location());
-  }
+  Visit(right);
+  ASSERT_EQ(destination.type(), right->location().type());

    __ bind(&done);
  }
=======================================
--- /branches/bleeding_edge/src/location.h      Thu Oct 29 03:35:29 2009
+++ /branches/bleeding_edge/src/location.h      Thu Oct 29 06:58:04 2009
@@ -35,14 +35,18 @@

  class Location BASE_EMBEDDED {
   public:
-  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; }
+  enum Type {
+    kUninitialized,
+    kEffect,
+    kValue
+  };
+
+  static Location Uninitialized() { return Location(kUninitialized); }
+  static Location Effect() { return Location(kEffect); }
+  static Location Value() { return Location(kValue); }
+
+  bool is_effect() { return type_ == kEffect; }
+  bool is_value() { return type_ == kValue; }

    Type type() { return type_; }

=======================================
--- /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Thu Oct 29 05:19:20  
2009
+++ /branches/bleeding_edge/src/x64/fast-codegen-x64.cc Thu Oct 29 06:58:04  
2009
@@ -118,11 +118,11 @@

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

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

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

  void FastCodeGenerator::DropAndMove(Location destination, Register source)  
{
    switch (destination.type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        __ addq(rsp, Immediate(kPointerSize));
        break;
-    case Location::VALUE:
+    case Location::kValue:
        __ movq(Operand(rsp, 0), source);
        break;
    }
@@ -364,12 +364,12 @@
      }
    }
    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        if (result_saved) __ addq(rsp, Immediate(kPointerSize));
        break;
-    case Location::VALUE:
+    case Location::kValue:
        if (!result_saved) __ push(rax);
        break;
    }
@@ -438,12 +438,12 @@
    }

    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::EFFECT:
+    case Location::kEffect:
        if (result_saved) __ addq(rsp, Immediate(kPointerSize));
        break;
-    case Location::VALUE:
+    case Location::kValue:
        if (!result_saved) __ push(rax);
        break;
    }
@@ -494,13 +494,13 @@
        ASSERT(rhs->location().is_value());
        Visit(rhs);
        switch (expr->location().type()) {
-        case Location::UNINITIALIZED:
+        case Location::kUninitialized:
            UNREACHABLE();
-        case Location::EFFECT:
+        case Location::kEffect:
            // Case 'var = temp'.  Discard right-hand-side temporary.
            Move(var->slot(), rhs->location());
            break;
-        case Location::VALUE:
+        case Location::kValue:
            // Case 'temp1 <- (var = temp0)'.  Preserve right-hand-side
            // temporary on the stack.
            __ movq(kScratchRegister, Operand(rsp, 0));
@@ -545,12 +545,12 @@
      __ addq(rsp, Immediate(kPointerSize));
    }
    switch (expr->location().type()) {
-    case Location::UNINITIALIZED:
+    case Location::kUninitialized:
        UNREACHABLE();
-    case Location::VALUE:
+    case Location::kValue:
        __ movq(Operand(rsp, 0), rax);
        break;
-    case Location::EFFECT:
+    case Location::kEffect:
        __ addq(rsp, Immediate(kPointerSize));
        break;
    }
@@ -722,14 +722,14 @@
      Visit(left);
      ASSERT(left->location().is_value());
      switch (destination.type()) {
-      case Location::UNINITIALIZED:
+      case Location::kUninitialized:
          UNREACHABLE();
-      case Location::EFFECT:
+      case Location::kEffect:
          // Pop the left-hand value into rax because we will not need it as  
the
          // final result.
          __ pop(rax);
          break;
-      case Location::VALUE:
+      case Location::kValue:
          // Copy the left-hand value into rax because we may need it as the
          // final result.
          __ movq(rax, Operand(rsp, 0));
@@ -770,12 +770,8 @@
      __ addq(rsp, Immediate(kPointerSize));
    }
    // Save or discard the right-hand value as needed.
-  if (right->AsLiteral() != NULL) {
-    Move(destination, right->AsLiteral());
-  } else {
-    Visit(right);
-    Move(destination, right->location());
-  }
+  Visit(right);
+  ASSERT_EQ(destination.type(), right->location().type());

    __ bind(&done);
  }

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

Reply via email to