Index: src/codegen-ia32.cc |
=================================================================== |
--- src/codegen-ia32.cc (revision 703) |
+++ src/codegen-ia32.cc (working copy) |
@@ -267,10 +267,8 @@ |
__ int3(); |
__ bind(&verified_true); |
} |
- |
// Update context local. |
__ mov(frame_->Context(), esi); |
- // Restore the arguments array pointer, if any. |
} |
// TODO(1241774): Improve this code: |
@@ -310,10 +308,10 @@ |
// This section stores the pointer to the arguments object that |
// was allocated and copied into above. If the address was not |
// saved to TOS, we push ecx onto the stack. |
- |
- // Store the arguments object. |
- // This must happen after context initialization because |
- // the arguments object may be stored in the context |
+ // |
+ // Store the arguments object. This must happen after context |
+ // initialization because the arguments object may be stored in the |
+ // context. |
if (arguments_object_allocated) { |
ASSERT(scope_->arguments() != NULL); |
ASSERT(scope_->arguments_shadow() != NULL); |
@@ -341,18 +339,17 @@ |
frame_->Pop(); // Value is no longer needed. |
} |
- // Generate code to 'execute' declarations and initialize |
- // functions (source elements). In case of an illegal |
- // redeclaration we need to handle that instead of processing the |
- // declarations. |
+ // Generate code to 'execute' declarations and initialize functions |
+ // (source elements). In case of an illegal redeclaration we need to |
+ // handle that instead of processing the declarations. |
if (scope_->HasIllegalRedeclaration()) { |
Comment cmnt(masm_, "[ illegal redeclarations"); |
scope_->VisitIllegalRedeclaration(this); |
} else { |
Comment cmnt(masm_, "[ declarations"); |
ProcessDeclarations(scope_->declarations()); |
- // Bail out if a stack-overflow exception occurred when |
- // processing declarations. |
+ // Bail out if a stack-overflow exception occurred when processing |
+ // declarations. |
if (HasStackOverflow()) return; |
} |
@@ -448,10 +445,11 @@ |
// Loads a value on TOS. If it is a boolean value, the result may have been |
-// (partially) translated into branches, or it may have set the condition code |
-// register. If force_cc is set, the value is forced to set the condition code |
-// register and no value is pushed. If the condition code register was set, |
-// has_cc() is true and cc_reg_ contains the condition to test for 'true'. |
+// (partially) translated into branches, or it may have set the condition |
+// code register. If force_cc is set, the value is forced to set the |
+// condition code register and no value is pushed. If the condition code |
+// register was set, has_cc() is true and cc_reg_ contains the condition to |
+// test for 'true'. |
void CodeGenerator::LoadCondition(Expression* x, |
TypeofState typeof_state, |
Label* true_target, |
@@ -463,6 +461,14 @@ |
Visit(x); |
} |
if (force_cc && !has_cc()) { |
+ // Convert the TOS value to a boolean in the condition code register. |
+ // Visiting an expression may possibly choose neither (a) to leave a |
+ // value in the condition code register nor (b) to leave a value in TOS |
+ // (eg, by compiling to only jumps to the targets). In that case the |
+ // code generated by ToBoolean is wrong because it assumes the value of |
+ // the expression in TOS. So long as there is always a value in TOS or |
+ // the condition code register when control falls through to here (there |
+ // is), the code generated by ToBoolean is dead and therefore safe. |
ToBoolean(true_target, false_target); |
} |
ASSERT(has_cc() || !force_cc); |
@@ -476,7 +482,6 @@ |
if (has_cc()) { |
// convert cc_reg_ into a bool |
- |
Label loaded, materialize_true; |
__ j(cc_reg_, &materialize_true); |
frame_->Push(Immediate(Factory::false_value())); |
@@ -663,7 +668,7 @@ |
frame_->Push(eax); // Undo the pop(eax) from above. |
ToBooleanStub stub; |
__ CallStub(&stub); |
- // Convert result (eax) to condition code. |
+ // Convert the result (eax) to condition code. |
__ test(eax, Operand(eax)); |
ASSERT(not_equal == not_zero); |
@@ -2198,7 +2203,6 @@ |
frame_->Pop(Operand::StaticVariable(handler_address)); |
frame_->Drop(StackHandlerConstants::kSize / kPointerSize - 1); |
// Next_sp popped. |
- // Preserve the TOS in a register across stack manipulation. |
frame_->Push(eax); |
// --- Finally block --- |