Index: src/full-codegen/arm/full-codegen-arm.cc |
diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc |
index 302db0ed8dc16ef07f8e5d1f432491e77ebc6ce8..6e6a65511a4e73df8b7379a0fc16c022f8798a7d 100644 |
--- a/src/full-codegen/arm/full-codegen-arm.cc |
+++ b/src/full-codegen/arm/full-codegen-arm.cc |
@@ -130,6 +130,7 @@ void FullCodeGenerator::Generate() { |
int locals_count = info->scope()->num_stack_slots(); |
// Generators allocate locals, if any, in context slots. |
DCHECK(!IsGeneratorFunction(info->literal()->kind()) || locals_count == 0); |
+ OperandStackDepthIncrement(locals_count); |
if (locals_count > 0) { |
if (locals_count >= 128) { |
Label ok; |
@@ -475,7 +476,7 @@ void FullCodeGenerator::EmitReturnSequence() { |
void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { |
DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
codegen()->GetVar(result_register(), var); |
- __ push(result_register()); |
+ codegen()->PushOperand(result_register()); |
} |
@@ -492,7 +493,7 @@ void FullCodeGenerator::AccumulatorValueContext::Plug( |
void FullCodeGenerator::StackValueContext::Plug( |
Heap::RootListIndex index) const { |
__ LoadRoot(result_register(), index); |
- __ push(result_register()); |
+ codegen()->PushOperand(result_register()); |
} |
@@ -527,7 +528,7 @@ void FullCodeGenerator::AccumulatorValueContext::Plug( |
void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const { |
// Immediates cannot be pushed directly. |
__ mov(result_register(), Operand(lit)); |
- __ push(result_register()); |
+ codegen()->PushOperand(result_register()); |
} |
@@ -561,41 +562,14 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const { |
} |
-void FullCodeGenerator::EffectContext::DropAndPlug(int count, |
- Register reg) const { |
- DCHECK(count > 0); |
- __ Drop(count); |
-} |
- |
- |
-void FullCodeGenerator::AccumulatorValueContext::DropAndPlug( |
- int count, |
- Register reg) const { |
- DCHECK(count > 0); |
- __ Drop(count); |
- __ Move(result_register(), reg); |
-} |
- |
- |
void FullCodeGenerator::StackValueContext::DropAndPlug(int count, |
Register reg) const { |
DCHECK(count > 0); |
- if (count > 1) __ Drop(count - 1); |
+ if (count > 1) codegen()->DropOperands(count - 1); |
__ str(reg, MemOperand(sp, 0)); |
} |
-void FullCodeGenerator::TestContext::DropAndPlug(int count, |
- Register reg) const { |
- DCHECK(count > 0); |
- // For simplicity we always test the accumulator register. |
- __ Drop(count); |
- __ Move(result_register(), reg); |
- codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); |
- codegen()->DoTest(this); |
-} |
- |
- |
void FullCodeGenerator::EffectContext::Plug(Label* materialize_true, |
Label* materialize_false) const { |
DCHECK(materialize_true == materialize_false); |
@@ -626,7 +600,7 @@ void FullCodeGenerator::StackValueContext::Plug( |
__ bind(materialize_false); |
__ LoadRoot(ip, Heap::kFalseValueRootIndex); |
__ bind(&done); |
- __ push(ip); |
+ codegen()->PushOperand(ip); |
} |
@@ -648,7 +622,7 @@ void FullCodeGenerator::StackValueContext::Plug(bool flag) const { |
Heap::RootListIndex value_root_index = |
flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
__ LoadRoot(ip, value_root_index); |
- __ push(ip); |
+ codegen()->PushOperand(ip); |
} |
@@ -891,11 +865,11 @@ void FullCodeGenerator::VisitFunctionDeclaration( |
case VariableLocation::LOOKUP: { |
Comment cmnt(masm_, "[ FunctionDeclaration"); |
__ mov(r2, Operand(variable->name())); |
- __ Push(r2); |
+ PushOperand(r2); |
// Push initial value for function declaration. |
VisitForStackValue(declaration->fun()); |
- __ Push(Smi::FromInt(variable->DeclarationPropertyAttributes())); |
- __ CallRuntime(Runtime::kDeclareLookupSlot); |
+ PushOperand(Smi::FromInt(variable->DeclarationPropertyAttributes())); |
+ CallRuntimeWithOperands(Runtime::kDeclareLookupSlot); |
break; |
} |
} |
@@ -993,7 +967,7 @@ void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
// Discard the test value and jump to the default if present, otherwise to |
// the end of the statement. |
__ bind(&next_test); |
- __ Drop(1); // Switch value is no longer needed. |
+ DropOperands(1); // Switch value is no longer needed. |
if (default_clause == NULL) { |
__ b(nested_statement.break_label()); |
} else { |
@@ -1027,6 +1001,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
// Get the object to enumerate over. |
SetExpressionAsStatementPosition(stmt->enumerable()); |
VisitForAccumulatorValue(stmt->enumerable()); |
+ OperandStackDepthIncrement(ForIn::kElementCount); |
// If the object is null or undefined, skip over the loop, otherwise convert |
// it to a JS receiver. See ECMA-262 version 5, section 12.6.4. |
@@ -1188,7 +1163,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
// Remove the pointers stored on the stack. |
__ bind(loop_statement.break_label()); |
- __ Drop(5); |
+ DropOperands(5); |
// Exit and decrement the loop depth. |
PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
@@ -1461,7 +1436,7 @@ void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) { |
Expression* expression = (property == NULL) ? NULL : property->value(); |
if (expression == NULL) { |
__ LoadRoot(r1, Heap::kNullValueRootIndex); |
- __ push(r1); |
+ PushOperand(r1); |
} else { |
VisitForStackValue(expression); |
if (NeedsHomeObject(expression)) { |
@@ -1506,7 +1481,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
Literal* key = property->key()->AsLiteral(); |
Expression* value = property->value(); |
if (!result_saved) { |
- __ push(r0); // Save result on stack |
+ PushOperand(r0); // Save result on stack |
result_saved = true; |
} |
switch (property->kind()) { |
@@ -1538,7 +1513,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
} |
// Duplicate receiver on stack. |
__ ldr(r0, MemOperand(sp)); |
- __ push(r0); |
+ PushOperand(r0); |
VisitForStackValue(key); |
VisitForStackValue(value); |
if (property->emit_store()) { |
@@ -1546,19 +1521,19 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
EmitSetHomeObject(value, 2, property->GetSlot()); |
} |
__ mov(r0, Operand(Smi::FromInt(SLOPPY))); // PropertyAttributes |
- __ push(r0); |
- __ CallRuntime(Runtime::kSetProperty); |
+ PushOperand(r0); |
+ CallRuntimeWithOperands(Runtime::kSetProperty); |
} else { |
- __ Drop(3); |
+ DropOperands(3); |
} |
break; |
case ObjectLiteral::Property::PROTOTYPE: |
// Duplicate receiver on stack. |
__ ldr(r0, MemOperand(sp)); |
- __ push(r0); |
+ PushOperand(r0); |
VisitForStackValue(value); |
DCHECK(property->emit_store()); |
- __ CallRuntime(Runtime::kInternalSetPrototype); |
+ CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
NO_REGISTERS); |
break; |
@@ -1582,13 +1557,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
it != accessor_table.end(); |
++it) { |
__ ldr(r0, MemOperand(sp)); // Duplicate receiver. |
- __ push(r0); |
+ PushOperand(r0); |
VisitForStackValue(it->first); |
EmitAccessor(it->second->getter); |
EmitAccessor(it->second->setter); |
__ mov(r0, Operand(Smi::FromInt(NONE))); |
- __ push(r0); |
- __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked); |
+ PushOperand(r0); |
+ CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked); |
} |
// Object literals have two parts. The "static" part on the left contains no |
@@ -1605,18 +1580,18 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
Expression* value = property->value(); |
if (!result_saved) { |
- __ push(r0); // Save result on the stack |
+ PushOperand(r0); // Save result on the stack |
result_saved = true; |
} |
__ ldr(r0, MemOperand(sp)); // Duplicate receiver. |
- __ push(r0); |
+ PushOperand(r0); |
if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { |
DCHECK(!property->is_computed_name()); |
VisitForStackValue(value); |
DCHECK(property->emit_store()); |
- __ CallRuntime(Runtime::kInternalSetPrototype); |
+ CallRuntimeWithOperands(Runtime::kInternalSetPrototype); |
PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), |
NO_REGISTERS); |
} else { |
@@ -1631,11 +1606,11 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
case ObjectLiteral::Property::COMPUTED: |
if (property->emit_store()) { |
- __ Push(Smi::FromInt(NONE)); |
- __ Push(Smi::FromInt(property->NeedsSetFunctionName())); |
- __ CallRuntime(Runtime::kDefineDataPropertyInLiteral); |
+ PushOperand(Smi::FromInt(NONE)); |
+ PushOperand(Smi::FromInt(property->NeedsSetFunctionName())); |
+ CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral); |
} else { |
- __ Drop(3); |
+ DropOperands(3); |
} |
break; |
@@ -1644,13 +1619,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
break; |
case ObjectLiteral::Property::GETTER: |
- __ Push(Smi::FromInt(NONE)); |
- __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked); |
+ PushOperand(Smi::FromInt(NONE)); |
+ CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); |
break; |
case ObjectLiteral::Property::SETTER: |
- __ Push(Smi::FromInt(NONE)); |
- __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked); |
+ PushOperand(Smi::FromInt(NONE)); |
+ CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); |
break; |
} |
} |
@@ -1716,7 +1691,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
if (!result_saved) { |
- __ push(r0); |
+ PushOperand(r0); |
result_saved = true; |
} |
VisitForAccumulatorValue(subexpr); |
@@ -1737,16 +1712,16 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
// (inclusive) and these elements gets appended to the array. Note that the |
// number elements an iterable produces is unknown ahead of time. |
if (array_index < length && result_saved) { |
- __ Pop(r0); |
+ PopOperand(r0); |
result_saved = false; |
} |
for (; array_index < length; array_index++) { |
Expression* subexpr = subexprs->at(array_index); |
- __ Push(r0); |
+ PushOperand(r0); |
DCHECK(!subexpr->IsSpread()); |
VisitForStackValue(subexpr); |
- __ CallRuntime(Runtime::kAppendElement); |
+ CallRuntimeWithOperands(Runtime::kAppendElement); |
PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
} |
@@ -1787,12 +1762,12 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
property->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
property->obj()->AsSuperPropertyReference()->home_object()); |
- __ Push(result_register()); |
+ PushOperand(result_register()); |
if (expr->is_compound()) { |
const Register scratch = r1; |
__ ldr(scratch, MemOperand(sp, kPointerSize)); |
- __ Push(scratch); |
- __ Push(result_register()); |
+ PushOperand(scratch); |
+ PushOperand(result_register()); |
} |
break; |
case KEYED_SUPER_PROPERTY: |
@@ -1801,14 +1776,14 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
VisitForStackValue( |
property->obj()->AsSuperPropertyReference()->home_object()); |
VisitForAccumulatorValue(property->key()); |
- __ Push(result_register()); |
+ PushOperand(result_register()); |
if (expr->is_compound()) { |
const Register scratch = r1; |
__ ldr(scratch, MemOperand(sp, 2 * kPointerSize)); |
- __ Push(scratch); |
+ PushOperand(scratch); |
__ ldr(scratch, MemOperand(sp, 2 * kPointerSize)); |
- __ Push(scratch); |
- __ Push(result_register()); |
+ PushOperand(scratch); |
+ PushOperand(result_register()); |
} |
break; |
case KEYED_PROPERTY: |
@@ -1854,7 +1829,7 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
} |
Token::Value op = expr->binary_op(); |
- __ push(r0); // Left operand goes on the stack. |
+ PushOperand(r0); // Left operand goes on the stack. |
VisitForAccumulatorValue(expr->value()); |
AccumulatorValueContext context(this); |
@@ -1947,7 +1922,7 @@ void FullCodeGenerator::VisitYield(Yield* expr) { |
__ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
__ bind(&post_runtime); |
- __ pop(result_register()); |
+ PopOperand(result_register()); |
EmitReturnSequence(); |
__ bind(&resume); |
@@ -1957,6 +1932,7 @@ void FullCodeGenerator::VisitYield(Yield* expr) { |
case Yield::kFinal: { |
// Pop value from top-of-stack slot, box result into result register. |
+ OperandStackDepthDecrement(1); |
EmitCreateIteratorResult(true); |
EmitUnwindAndReturn(); |
break; |
@@ -1977,7 +1953,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
// r1 will hold the generator object until the activation has been resumed. |
VisitForStackValue(generator); |
VisitForAccumulatorValue(value); |
- __ pop(r1); |
+ PopOperand(r1); |
// Store input value into generator object. |
__ str(result_register(), |
@@ -2073,6 +2049,25 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
context()->Plug(result_register()); |
} |
+void FullCodeGenerator::PushOperands(Register reg1, Register reg2) { |
+ OperandStackDepthIncrement(2); |
+ __ Push(reg1, reg2); |
+} |
+ |
+void FullCodeGenerator::PopOperands(Register reg1, Register reg2) { |
+ OperandStackDepthDecrement(2); |
+ __ Pop(reg1, reg2); |
+} |
+ |
+void FullCodeGenerator::EmitOperandStackDepthCheck() { |
+ if (FLAG_debug_code) { |
+ int expected_diff = StandardFrameConstants::kFixedFrameSizeFromFp + |
+ operand_stack_depth_ * kPointerSize; |
+ __ sub(r0, fp, sp); |
+ __ cmp(r0, Operand(expected_diff)); |
+ __ Assert(eq, kUnexpectedStackDepth); |
+ } |
+} |
void FullCodeGenerator::EmitCreateIteratorResult(bool done) { |
Label allocate, done_allocate; |
@@ -2110,34 +2105,6 @@ void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
} |
-void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
- // Stack: receiver, home_object. |
- SetExpressionPosition(prop); |
- Literal* key = prop->key()->AsLiteral(); |
- DCHECK(!key->value()->IsSmi()); |
- DCHECK(prop->IsSuperAccess()); |
- |
- __ Push(key->value()); |
- __ CallRuntime(Runtime::kLoadFromSuper); |
-} |
- |
- |
-void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
- SetExpressionPosition(prop); |
- Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
- __ mov(LoadDescriptor::SlotRegister(), |
- Operand(SmiFromSlot(prop->PropertyFeedbackSlot()))); |
- CallIC(ic); |
-} |
- |
- |
-void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
- // Stack: receiver, home_object, key. |
- SetExpressionPosition(prop); |
- __ CallRuntime(Runtime::kLoadKeyedFromSuper); |
-} |
- |
- |
void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
Token::Value op, |
Expression* left_expr, |
@@ -2150,7 +2117,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
// Get the arguments. |
Register left = r1; |
Register right = r0; |
- __ pop(left); |
+ PopOperand(left); |
// Perform combined smi check on both operands. |
__ orr(scratch1, left, Operand(right)); |
@@ -2242,7 +2209,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { |
} else { |
__ ldr(scratch, MemOperand(sp, 0)); // prototype |
} |
- __ push(scratch); |
+ PushOperand(scratch); |
EmitPropertyKey(property, lit->GetIdForProperty(i)); |
// The static prototype property is read only. We handle the non computed |
@@ -2265,19 +2232,19 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { |
case ObjectLiteral::Property::PROTOTYPE: |
UNREACHABLE(); |
case ObjectLiteral::Property::COMPUTED: |
- __ Push(Smi::FromInt(DONT_ENUM)); |
- __ Push(Smi::FromInt(property->NeedsSetFunctionName())); |
- __ CallRuntime(Runtime::kDefineDataPropertyInLiteral); |
+ PushOperand(Smi::FromInt(DONT_ENUM)); |
+ PushOperand(Smi::FromInt(property->NeedsSetFunctionName())); |
+ CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral); |
break; |
case ObjectLiteral::Property::GETTER: |
- __ Push(Smi::FromInt(DONT_ENUM)); |
- __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked); |
+ PushOperand(Smi::FromInt(DONT_ENUM)); |
+ CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); |
break; |
case ObjectLiteral::Property::SETTER: |
- __ Push(Smi::FromInt(DONT_ENUM)); |
- __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked); |
+ PushOperand(Smi::FromInt(DONT_ENUM)); |
+ CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); |
break; |
default: |
@@ -2288,7 +2255,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { |
void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { |
- __ pop(r1); |
+ PopOperand(r1); |
Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); |
JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
CallIC(code, expr->BinaryOperationFeedbackId()); |
@@ -2312,10 +2279,10 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, |
break; |
} |
case NAMED_PROPERTY: { |
- __ push(r0); // Preserve value. |
+ PushOperand(r0); // Preserve value. |
VisitForAccumulatorValue(prop->obj()); |
__ Move(StoreDescriptor::ReceiverRegister(), r0); |
- __ pop(StoreDescriptor::ValueRegister()); // Restore value. |
+ PopOperand(StoreDescriptor::ValueRegister()); // Restore value. |
__ mov(StoreDescriptor::NameRegister(), |
Operand(prop->key()->AsLiteral()->value())); |
EmitLoadStoreICSlot(slot); |
@@ -2323,7 +2290,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, |
break; |
} |
case NAMED_SUPER_PROPERTY: { |
- __ Push(r0); |
+ PushOperand(r0); |
VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
prop->obj()->AsSuperPropertyReference()->home_object()); |
@@ -2340,7 +2307,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, |
break; |
} |
case KEYED_SUPER_PROPERTY: { |
- __ Push(r0); |
+ PushOperand(r0); |
VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
VisitForStackValue( |
prop->obj()->AsSuperPropertyReference()->home_object()); |
@@ -2360,12 +2327,12 @@ void FullCodeGenerator::EmitAssignment(Expression* expr, |
break; |
} |
case KEYED_PROPERTY: { |
- __ push(r0); // Preserve value. |
+ PushOperand(r0); // Preserve value. |
VisitForStackValue(prop->obj()); |
VisitForAccumulatorValue(prop->key()); |
__ Move(StoreDescriptor::NameRegister(), r0); |
- __ Pop(StoreDescriptor::ValueRegister(), |
- StoreDescriptor::ReceiverRegister()); |
+ PopOperands(StoreDescriptor::ValueRegister(), |
+ StoreDescriptor::ReceiverRegister()); |
EmitLoadStoreICSlot(slot); |
Handle<Code> ic = |
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
@@ -2504,7 +2471,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
__ mov(StoreDescriptor::NameRegister(), |
Operand(prop->key()->AsLiteral()->value())); |
- __ pop(StoreDescriptor::ReceiverRegister()); |
+ PopOperand(StoreDescriptor::ReceiverRegister()); |
EmitLoadStoreICSlot(expr->AssignmentSlot()); |
CallStoreIC(); |
@@ -2521,10 +2488,11 @@ void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) { |
Literal* key = prop->key()->AsLiteral(); |
DCHECK(key != NULL); |
- __ Push(key->value()); |
- __ Push(r0); |
- __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict |
- : Runtime::kStoreToSuper_Sloppy)); |
+ PushOperand(key->value()); |
+ PushOperand(r0); |
+ CallRuntimeWithOperands(is_strict(language_mode()) |
+ ? Runtime::kStoreToSuper_Strict |
+ : Runtime::kStoreToSuper_Sloppy); |
} |
@@ -2534,16 +2502,17 @@ void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) { |
// stack : receiver ('this'), home_object, key |
DCHECK(prop != NULL); |
- __ Push(r0); |
- __ CallRuntime((is_strict(language_mode()) |
- ? Runtime::kStoreKeyedToSuper_Strict |
- : Runtime::kStoreKeyedToSuper_Sloppy)); |
+ PushOperand(r0); |
+ CallRuntimeWithOperands(is_strict(language_mode()) |
+ ? Runtime::kStoreKeyedToSuper_Strict |
+ : Runtime::kStoreKeyedToSuper_Sloppy); |
} |
void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
// Assignment to a property, using a keyed store IC. |
- __ Pop(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister()); |
+ PopOperands(StoreDescriptor::ReceiverRegister(), |
+ StoreDescriptor::NameRegister()); |
DCHECK(StoreDescriptor::ValueRegister().is(r0)); |
Handle<Code> ic = |
@@ -2578,7 +2547,7 @@ void FullCodeGenerator::VisitProperty(Property* expr) { |
VisitForStackValue(expr->obj()); |
VisitForAccumulatorValue(expr->key()); |
__ Move(LoadDescriptor::NameRegister(), r0); |
- __ pop(LoadDescriptor::ReceiverRegister()); |
+ PopOperand(LoadDescriptor::ReceiverRegister()); |
EmitKeyedPropertyLoad(expr); |
} else { |
VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); |
@@ -2617,7 +2586,7 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
// Push undefined as receiver. This is patched in the method prologue if it |
// is a sloppy mode method. |
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
- __ push(ip); |
+ PushOperand(ip); |
convert_mode = ConvertReceiverMode::kNullOrUndefined; |
} else { |
// Load the function from the receiver. |
@@ -2628,7 +2597,7 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); |
// Push the target function under the receiver. |
__ ldr(ip, MemOperand(sp, 0)); |
- __ push(ip); |
+ PushOperand(ip); |
__ str(r0, MemOperand(sp, kPointerSize)); |
convert_mode = ConvertReceiverMode::kNotNullOrUndefined; |
} |
@@ -2651,11 +2620,11 @@ void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
VisitForStackValue(super_ref->home_object()); |
VisitForAccumulatorValue(super_ref->this_var()); |
- __ Push(r0); |
- __ Push(r0); |
+ PushOperand(r0); |
+ PushOperand(r0); |
__ ldr(scratch, MemOperand(sp, kPointerSize * 2)); |
- __ Push(scratch); |
- __ Push(key->value()); |
+ PushOperand(scratch); |
+ PushOperand(key->value()); |
// Stack here: |
// - home_object |
@@ -2663,7 +2632,7 @@ void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) { |
// - this (receiver) <-- LoadFromSuper will pop here and below. |
// - home_object |
// - key |
- __ CallRuntime(Runtime::kLoadFromSuper); |
+ CallRuntimeWithOperands(Runtime::kLoadFromSuper); |
// Replace home_object with target function. |
__ str(r0, MemOperand(sp, kPointerSize)); |
@@ -2692,7 +2661,7 @@ void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
// Push the target function under the receiver. |
__ ldr(ip, MemOperand(sp, 0)); |
- __ push(ip); |
+ PushOperand(ip); |
__ str(r0, MemOperand(sp, kPointerSize)); |
EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined); |
@@ -2711,10 +2680,10 @@ void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); |
VisitForStackValue(super_ref->home_object()); |
VisitForAccumulatorValue(super_ref->this_var()); |
- __ Push(r0); |
- __ Push(r0); |
+ PushOperand(r0); |
+ PushOperand(r0); |
__ ldr(scratch, MemOperand(sp, kPointerSize * 2)); |
- __ Push(scratch); |
+ PushOperand(scratch); |
VisitForStackValue(prop->key()); |
// Stack here: |
@@ -2723,7 +2692,7 @@ void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { |
// - this (receiver) <-- LoadKeyedFromSuper will pop here and below. |
// - home_object |
// - key |
- __ CallRuntime(Runtime::kLoadKeyedFromSuper); |
+ CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); |
// Replace home_object with target function. |
__ str(r0, MemOperand(sp, kPointerSize)); |
@@ -2761,6 +2730,7 @@ void FullCodeGenerator::EmitCall(Call* expr, ConvertReceiverMode mode) { |
// Don't assign a type feedback id to the IC, since type feedback is provided |
// by the vector above. |
CallIC(ic); |
+ OperandStackDepthDecrement(arg_count + 1); |
RecordJSReturnSite(expr); |
// Restore context register. |
@@ -2807,7 +2777,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
// and the object holding it (returned in edx). |
__ Push(callee->name()); |
__ CallRuntime(Runtime::kLoadLookupSlotForCall); |
- __ Push(r0, r1); // Function, receiver. |
+ PushOperands(r0, r1); // Function, receiver. |
PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); |
// If fast case code has been generated, emit code to push the |
@@ -2829,7 +2799,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
VisitForStackValue(callee); |
// refEnv.WithBaseObject() |
__ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
- __ push(r2); // Reserved receiver slot. |
+ PushOperand(r2); // Reserved receiver slot. |
} |
} |
@@ -2866,6 +2836,7 @@ void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
expr->tail_call_mode()), |
RelocInfo::CODE_TARGET); |
+ OperandStackDepthDecrement(arg_count + 1); |
RecordJSReturnSite(expr); |
// Restore context register. |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
@@ -2906,6 +2877,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
CallConstructStub stub(isolate()); |
__ Call(stub.GetCode(), RelocInfo::CODE_TARGET); |
+ OperandStackDepthDecrement(arg_count + 1); |
PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
// Restore context register. |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
@@ -2926,7 +2898,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
FieldMemOperand(result_register(), HeapObject::kMapOffset)); |
__ ldr(result_register(), |
FieldMemOperand(result_register(), Map::kPrototypeOffset)); |
- __ Push(result_register()); |
+ PushOperand(result_register()); |
// Push the arguments ("left-to-right") on the stack. |
ZoneList<Expression*>* args = expr->arguments(); |
@@ -2948,6 +2920,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) { |
__ ldr(r1, MemOperand(sp, arg_count * kPointerSize)); |
__ Call(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
+ OperandStackDepthDecrement(arg_count + 1); |
RecordJSReturnSite(expr); |
@@ -3167,7 +3140,7 @@ void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
VisitForStackValue(args->at(0)); // index |
VisitForStackValue(args->at(1)); // value |
VisitForAccumulatorValue(args->at(2)); // string |
- __ Pop(index, value); |
+ PopOperands(index, value); |
if (FLAG_debug_code) { |
__ SmiTst(value); |
@@ -3200,7 +3173,7 @@ void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { |
VisitForStackValue(args->at(0)); // index |
VisitForStackValue(args->at(1)); // value |
VisitForAccumulatorValue(args->at(2)); // string |
- __ Pop(index, value); |
+ PopOperands(index, value); |
if (FLAG_debug_code) { |
__ SmiTst(value); |
@@ -3268,7 +3241,7 @@ void FullCodeGenerator::EmitStringCharCodeAt(CallRuntime* expr) { |
Register index = r0; |
Register result = r3; |
- __ pop(object); |
+ PopOperand(object); |
Label need_conversion; |
Label index_out_of_range; |
@@ -3314,7 +3287,7 @@ void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) { |
Register scratch = r3; |
Register result = r0; |
- __ pop(object); |
+ PopOperand(object); |
Label need_conversion; |
Label index_out_of_range; |
@@ -3364,6 +3337,7 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) { |
// Call the target. |
__ mov(r0, Operand(argc)); |
__ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
+ OperandStackDepthDecrement(argc + 1); |
// Restore context register. |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
// Discard the function left on TOS. |
@@ -3449,7 +3423,7 @@ void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) { |
__ b(&done); |
__ bind(&runtime); |
- __ CallRuntime(Runtime::kCreateIterResultObject); |
+ CallRuntimeWithOperands(Runtime::kCreateIterResultObject); |
__ bind(&done); |
context()->Plug(r0); |
@@ -3459,7 +3433,7 @@ void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) { |
void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
// Push undefined as the receiver. |
__ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
- __ push(r0); |
+ PushOperand(r0); |
__ LoadNativeContextSlot(expr->context_index(), r0); |
} |
@@ -3474,6 +3448,7 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
__ mov(r0, Operand(arg_count)); |
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined), |
RelocInfo::CODE_TARGET); |
+ OperandStackDepthDecrement(arg_count + 1); |
} |
@@ -3487,7 +3462,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
// Push the target function under the receiver. |
__ ldr(ip, MemOperand(sp, 0)); |
- __ push(ip); |
+ PushOperand(ip); |
__ str(r0, MemOperand(sp, kPointerSize)); |
// Push the arguments ("left-to-right"). |
@@ -3523,6 +3498,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
// Call the C runtime function. |
PrepareForBailoutForId(expr->CallId(), NO_REGISTERS); |
__ CallRuntime(expr->function(), arg_count); |
+ OperandStackDepthDecrement(arg_count); |
context()->Plug(r0); |
} |
} |
@@ -3540,9 +3516,9 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
if (property != NULL) { |
VisitForStackValue(property->obj()); |
VisitForStackValue(property->key()); |
- __ CallRuntime(is_strict(language_mode()) |
- ? Runtime::kDeleteProperty_Strict |
- : Runtime::kDeleteProperty_Sloppy); |
+ CallRuntimeWithOperands(is_strict(language_mode()) |
+ ? Runtime::kDeleteProperty_Strict |
+ : Runtime::kDeleteProperty_Sloppy); |
context()->Plug(r0); |
} else if (proxy != NULL) { |
Variable* var = proxy->var(); |
@@ -3608,6 +3584,7 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
&materialize_false, |
&materialize_true, |
&materialize_true); |
+ if (!context()->IsAccumulatorValue()) OperandStackDepthIncrement(1); |
__ bind(&materialize_true); |
PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS); |
__ LoadRoot(r0, Heap::kTrueValueRootIndex); |
@@ -3658,7 +3635,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
// Reserve space for result of postfix operation. |
if (expr->is_postfix() && !context()->IsEffect()) { |
__ mov(ip, Operand(Smi::FromInt(0))); |
- __ push(ip); |
+ PushOperand(ip); |
} |
switch (assign_type) { |
case NAMED_PROPERTY: { |
@@ -3673,11 +3650,11 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); |
VisitForAccumulatorValue( |
prop->obj()->AsSuperPropertyReference()->home_object()); |
- __ Push(result_register()); |
+ PushOperand(result_register()); |
const Register scratch = r1; |
__ ldr(scratch, MemOperand(sp, kPointerSize)); |
- __ Push(scratch); |
- __ Push(result_register()); |
+ PushOperand(scratch); |
+ PushOperand(result_register()); |
EmitNamedSuperPropertyLoad(prop); |
break; |
} |
@@ -3687,13 +3664,13 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
VisitForStackValue( |
prop->obj()->AsSuperPropertyReference()->home_object()); |
VisitForAccumulatorValue(prop->key()); |
- __ Push(result_register()); |
+ PushOperand(result_register()); |
const Register scratch = r1; |
__ ldr(scratch, MemOperand(sp, 2 * kPointerSize)); |
- __ Push(scratch); |
+ PushOperand(scratch); |
__ ldr(scratch, MemOperand(sp, 2 * kPointerSize)); |
- __ Push(scratch); |
- __ Push(result_register()); |
+ PushOperand(scratch); |
+ PushOperand(result_register()); |
EmitKeyedSuperPropertyLoad(prop); |
break; |
} |
@@ -3777,7 +3754,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
// of the stack. |
switch (assign_type) { |
case VARIABLE: |
- __ push(r0); |
+ PushOperand(r0); |
break; |
case NAMED_PROPERTY: |
__ str(r0, MemOperand(sp, kPointerSize)); |
@@ -3835,7 +3812,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
case NAMED_PROPERTY: { |
__ mov(StoreDescriptor::NameRegister(), |
Operand(prop->key()->AsLiteral()->value())); |
- __ pop(StoreDescriptor::ReceiverRegister()); |
+ PopOperand(StoreDescriptor::ReceiverRegister()); |
EmitLoadStoreICSlot(expr->CountSlot()); |
CallStoreIC(); |
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
@@ -3871,8 +3848,8 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
break; |
} |
case KEYED_PROPERTY: { |
- __ Pop(StoreDescriptor::ReceiverRegister(), |
- StoreDescriptor::NameRegister()); |
+ PopOperands(StoreDescriptor::ReceiverRegister(), |
+ StoreDescriptor::NameRegister()); |
Handle<Code> ic = |
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code(); |
EmitLoadStoreICSlot(expr->CountSlot()); |
@@ -3994,7 +3971,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
switch (op) { |
case Token::IN: |
VisitForStackValue(expr->right()); |
- __ CallRuntime(Runtime::kHasProperty); |
+ CallRuntimeWithOperands(Runtime::kHasProperty); |
PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); |
__ CompareRoot(r0, Heap::kTrueValueRootIndex); |
Split(eq, if_true, if_false, fall_through); |
@@ -4002,7 +3979,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
case Token::INSTANCEOF: { |
VisitForAccumulatorValue(expr->right()); |
- __ pop(r1); |
+ PopOperand(r1); |
InstanceOfStub stub(isolate()); |
__ CallStub(&stub); |
PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); |
@@ -4014,7 +3991,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
default: { |
VisitForAccumulatorValue(expr->right()); |
Condition cond = CompareIC::ComputeCondition(op); |
- __ pop(r1); |
+ PopOperand(r1); |
bool inline_smi_code = ShouldInlineSmiCase(op); |
JumpPatchSite patch_site(masm_); |
@@ -4115,7 +4092,7 @@ void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
DCHECK(closure_scope->is_function_scope()); |
__ ldr(ip, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
} |
- __ push(ip); |
+ PushOperand(ip); |
} |
@@ -4129,7 +4106,7 @@ void FullCodeGenerator::EnterFinallyBlock() { |
ExternalReference::address_of_pending_message_obj(isolate()); |
__ mov(ip, Operand(pending_message_obj)); |
__ ldr(r1, MemOperand(ip)); |
- __ push(r1); |
+ PushOperand(r1); |
ClearPendingMessage(); |
} |
@@ -4138,7 +4115,7 @@ void FullCodeGenerator::EnterFinallyBlock() { |
void FullCodeGenerator::ExitFinallyBlock() { |
DCHECK(!result_register().is(r1)); |
// Restore pending message from stack. |
- __ pop(r1); |
+ PopOperand(r1); |
ExternalReference pending_message_obj = |
ExternalReference::address_of_pending_message_obj(isolate()); |
__ mov(ip, Operand(pending_message_obj)); |