Do not visit slots in the top-level code generator's backend.
authorkmillikin@chromium.org <kmillikin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 16 Oct 2009 09:46:09 +0000 (09:46 +0000)
committerkmillikin@chromium.org <kmillikin@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 16 Oct 2009 09:46:09 +0000 (09:46 +0000)
Slots appear only indirectly in the AST (through variables linked to
variable proxies).  Slots are shared among variable references, so
putting compilation-time state on them is potentially a source of
bugs.  Avoid it for now.

Review URL: http://codereview.chromium.org/284009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3079 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/fast-codegen-arm.cc
src/fast-codegen.cc
src/ia32/fast-codegen-ia32.cc
src/x64/fast-codegen-x64.cc

index 4f897b93def9d84ddb11de772603734eb1f9178f..d2e620cfdf1ca1e0009e62153d96a522fa9e2fb4 100644 (file)
@@ -125,13 +125,20 @@ void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
 }
 
 
-void FastCodeGenerator::VisitSlot(Slot* expr) {
-  Comment cmnt(masm_, "[ Slot");
-  if (expr->location().is_temporary()) {
-    __ ldr(ip, MemOperand(fp, SlotOffset(expr)));
-    __ push(ip);
-  } else {
-    ASSERT(expr->location().is_nowhere());
+void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
+  Comment cmnt(masm_, "[ VariableProxy");
+  Expression* rewrite = expr->var()->rewrite();
+  ASSERT(rewrite != NULL);
+
+  Slot* slot = rewrite->AsSlot();
+  ASSERT(slot != NULL);
+  { Comment cmnt(masm_, "[ Slot");
+    if (expr->location().is_temporary()) {
+      __ ldr(ip, MemOperand(fp, SlotOffset(slot)));
+      __ push(ip);
+    } else {
+      ASSERT(expr->location().is_nowhere());
+    }
   }
 }
 
index 169520c5e303f450244e51fe809e4f9e62834318..4ec6a524f269a673040729f3c83db403cbb64888 100644 (file)
@@ -190,14 +190,9 @@ void FastCodeGenerator::VisitConditional(Conditional* expr) {
 }
 
 
-void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
-  Comment cmnt(masm_, "[ VariableProxy");
-  Expression* rewrite = expr->var()->rewrite();
-  ASSERT(rewrite != NULL);
-
-  // Forward to the proxy's rewrite.
-  rewrite->set_location(expr->location());
-  Visit(rewrite);
+void FastCodeGenerator::VisitSlot(Slot* expr) {
+  // Slots do not appear directly in the AST.
+  UNREACHABLE();
 }
 
 
index c84173b62f2d2b6a9748210d610851b7c9e517bf..ee1b92d09a3f1d932fa1ffd9761af18692b1e26c 100644 (file)
@@ -115,12 +115,19 @@ void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
 }
 
 
-void FastCodeGenerator::VisitSlot(Slot* expr) {
-  Comment cmnt(masm_, "[ Slot");
-  if (expr->location().is_temporary()) {
-    __ push(Operand(ebp, SlotOffset(expr)));
-  } else {
-    ASSERT(expr->location().is_nowhere());
+void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
+  Comment cmnt(masm_, "[ VariableProxy");
+  Expression* rewrite = expr->var()->rewrite();
+  ASSERT(rewrite != NULL);
+
+  Slot* slot = rewrite->AsSlot();
+  ASSERT(slot != NULL);
+  { Comment cmnt(masm_, "[ Slot");
+    if (expr->location().is_temporary()) {
+      __ push(Operand(ebp, SlotOffset(slot)));
+    } else {
+      ASSERT(expr->location().is_nowhere());
+    }
   }
 }
 
index 53de859ecad33a5f6f3faef11ad14f489f04e93b..c43383631b3880415fb8599074a22921e8f28472 100644 (file)
@@ -132,12 +132,19 @@ void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) {
 }
 
 
-void FastCodeGenerator::VisitSlot(Slot* expr) {
-  Comment cmnt(masm_, "[ Slot");
-  if (expr->location().is_temporary()) {
-    __ push(Operand(rbp, SlotOffset(expr)));
-  } else {
-    ASSERT(expr->location().is_nowhere());
+void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
+  Comment cmnt(masm_, "[ VariableProxy");
+  Expression* rewrite = expr->var()->rewrite();
+  ASSERT(rewrite != NULL);
+
+  Slot* slot = rewrite->AsSlot();
+  ASSERT(slot != NULL);
+  { Comment cmnt(masm_, "[ Slot");
+    if (expr->location().is_temporary()) {
+      __ push(Operand(rbp, SlotOffset(slot)));
+    } else {
+      ASSERT(expr->location().is_nowhere());
+    }
   }
 }