Index: src/ia32/fast-codegen-ia32.cc |
=================================================================== |
--- src/ia32/fast-codegen-ia32.cc (revision 3167) |
+++ src/ia32/fast-codegen-ia32.cc (working copy) |
@@ -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; |
} |
@@ -231,6 +238,33 @@ |
} |
+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) { |
Comment cmnt(masm_, "[ ObjectLiteral"); |
Label exists; |
@@ -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,43 +352,18 @@ |
} |
} |
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) { |
Comment cmnt(masm_, "[ ArrayLiteral"); |
Label make_clone; |
@@ -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. |