Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: src/full-codegen/mips/full-codegen-mips.cc

Issue 1706283002: [fullcodegen] Implement operand stack depth tracking. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Turn off verification. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | src/full-codegen/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/full-codegen/mips/full-codegen-mips.cc
diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc
index 7c7e690358f68d97c338cc3803c21600d59de5f3..c8ce20459069312542acdbb3ca94268baaa4d26a 100644
--- a/src/full-codegen/mips/full-codegen-mips.cc
+++ b/src/full-codegen/mips/full-codegen-mips.cc
@@ -139,6 +139,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;
@@ -465,7 +466,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());
}
@@ -482,7 +483,7 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(
void FullCodeGenerator::StackValueContext::Plug(
Heap::RootListIndex index) const {
__ LoadRoot(result_register(), index);
- __ push(result_register());
+ codegen()->PushOperand(result_register());
}
@@ -517,7 +518,7 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(
void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
// Immediates cannot be pushed directly.
__ li(result_register(), Operand(lit));
- __ push(result_register());
+ codegen()->PushOperand(result_register());
}
@@ -551,41 +552,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);
__ sw(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);
@@ -609,6 +583,7 @@ void FullCodeGenerator::AccumulatorValueContext::Plug(
void FullCodeGenerator::StackValueContext::Plug(
Label* materialize_true,
Label* materialize_false) const {
+ codegen()->OperandStackDepthIncrement(1);
Label done;
__ bind(materialize_true);
__ LoadRoot(at, Heap::kTrueValueRootIndex);
@@ -640,7 +615,7 @@ void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
Heap::RootListIndex value_root_index =
flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
__ LoadRoot(at, value_root_index);
- __ push(at);
+ codegen()->PushOperand(at);
}
@@ -887,11 +862,11 @@ void FullCodeGenerator::VisitFunctionDeclaration(
case VariableLocation::LOOKUP: {
Comment cmnt(masm_, "[ FunctionDeclaration");
__ li(a2, Operand(variable->name()));
- __ Push(a2);
+ PushOperand(a2);
// 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;
}
}
@@ -988,7 +963,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) {
__ Branch(nested_statement.break_label());
} else {
@@ -1023,6 +998,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
SetExpressionAsStatementPosition(stmt->enumerable());
VisitForAccumulatorValue(stmt->enumerable());
__ mov(a0, result_register());
+ 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.
@@ -1182,7 +1158,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);
@@ -1458,7 +1434,7 @@ void FullCodeGenerator::EmitAccessor(ObjectLiteralProperty* property) {
Expression* expression = (property == NULL) ? NULL : property->value();
if (expression == NULL) {
__ LoadRoot(a1, Heap::kNullValueRootIndex);
- __ push(a1);
+ PushOperand(a1);
} else {
VisitForStackValue(expression);
if (NeedsHomeObject(expression)) {
@@ -1502,7 +1478,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
Literal* key = property->key()->AsLiteral();
Expression* value = property->value();
if (!result_saved) {
- __ push(v0); // Save result on stack.
+ PushOperand(v0); // Save result on stack.
result_saved = true;
}
switch (property->kind()) {
@@ -1535,7 +1511,7 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
}
// Duplicate receiver on stack.
__ lw(a0, MemOperand(sp));
- __ push(a0);
+ PushOperand(a0);
VisitForStackValue(key);
VisitForStackValue(value);
if (property->emit_store()) {
@@ -1543,19 +1519,19 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
EmitSetHomeObject(value, 2, property->GetSlot());
}
__ li(a0, Operand(Smi::FromInt(SLOPPY))); // PropertyAttributes.
- __ push(a0);
- __ CallRuntime(Runtime::kSetProperty);
+ PushOperand(a0);
+ CallRuntimeWithOperands(Runtime::kSetProperty);
} else {
- __ Drop(3);
+ DropOperands(3);
}
break;
case ObjectLiteral::Property::PROTOTYPE:
// Duplicate receiver on stack.
__ lw(a0, MemOperand(sp));
- __ push(a0);
+ PushOperand(a0);
VisitForStackValue(value);
DCHECK(property->emit_store());
- __ CallRuntime(Runtime::kInternalSetPrototype);
+ CallRuntimeWithOperands(Runtime::kInternalSetPrototype);
PrepareForBailoutForId(expr->GetIdForPropertySet(property_index),
NO_REGISTERS);
break;
@@ -1578,13 +1554,13 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
it != accessor_table.end();
++it) {
__ lw(a0, MemOperand(sp)); // Duplicate receiver.
- __ push(a0);
+ PushOperand(a0);
VisitForStackValue(it->first);
EmitAccessor(it->second->getter);
EmitAccessor(it->second->setter);
__ li(a0, Operand(Smi::FromInt(NONE)));
- __ push(a0);
- __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked);
+ PushOperand(a0);
+ CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked);
}
// Object literals have two parts. The "static" part on the left contains no
@@ -1601,18 +1577,18 @@ void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
Expression* value = property->value();
if (!result_saved) {
- __ push(v0); // Save result on the stack
+ PushOperand(v0); // Save result on the stack
result_saved = true;
}
__ lw(a0, MemOperand(sp)); // Duplicate receiver.
- __ push(a0);
+ PushOperand(a0);
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 {
@@ -1627,11 +1603,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;
@@ -1640,13 +1616,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;
}
}
@@ -1711,7 +1687,7 @@ void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
if (!result_saved) {
- __ push(v0); // array literal
+ PushOperand(v0); // array literal
result_saved = true;
}
@@ -1734,16 +1710,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(v0);
+ PopOperand(v0);
result_saved = false;
}
for (; array_index < length; array_index++) {
Expression* subexpr = subexprs->at(array_index);
- __ Push(v0);
+ PushOperand(v0);
DCHECK(!subexpr->IsSpread());
VisitForStackValue(subexpr);
- __ CallRuntime(Runtime::kAppendElement);
+ CallRuntimeWithOperands(Runtime::kAppendElement);
PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
}
@@ -1784,11 +1760,11 @@ 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 = a1;
__ lw(scratch, MemOperand(sp, kPointerSize));
- __ Push(scratch, result_register());
+ PushOperands(scratch, result_register());
}
break;
case KEYED_SUPER_PROPERTY: {
@@ -1799,11 +1775,11 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) {
property->obj()->AsSuperPropertyReference()->home_object());
__ Move(scratch, result_register());
VisitForAccumulatorValue(property->key());
- __ Push(scratch, result_register());
+ PushOperands(scratch, result_register());
if (expr->is_compound()) {
const Register scratch1 = t0;
__ lw(scratch1, MemOperand(sp, 2 * kPointerSize));
- __ Push(scratch1, scratch, result_register());
+ PushOperands(scratch1, scratch, result_register());
}
break;
}
@@ -1851,7 +1827,7 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) {
}
Token::Value op = expr->binary_op();
- __ push(v0); // Left operand goes on the stack.
+ PushOperand(v0); // Left operand goes on the stack.
VisitForAccumulatorValue(expr->value());
AccumulatorValueContext context(this);
@@ -1943,7 +1919,7 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
__ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
__ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
__ bind(&post_runtime);
- __ pop(result_register());
+ PopOperand(result_register());
EmitReturnSequence();
__ bind(&resume);
@@ -1953,6 +1929,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;
@@ -1973,7 +1950,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// a1 will hold the generator object until the activation has been resumed.
VisitForStackValue(generator);
VisitForAccumulatorValue(value);
- __ pop(a1);
+ PopOperand(a1);
// Store input value into generator object.
__ sw(result_register(),
@@ -2059,6 +2036,36 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
context()->Plug(result_register());
}
+void FullCodeGenerator::PushOperands(Register reg1, Register reg2) {
+ OperandStackDepthIncrement(2);
+ __ Push(reg1, reg2);
+}
+
+void FullCodeGenerator::PushOperands(Register reg1, Register reg2,
+ Register reg3) {
+ OperandStackDepthIncrement(3);
+ __ Push(reg1, reg2, reg3);
+}
+
+void FullCodeGenerator::PushOperands(Register reg1, Register reg2,
+ Register reg3, Register reg4) {
+ OperandStackDepthIncrement(4);
+ __ Push(reg1, reg2, reg3, reg4);
+}
+
+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;
+ __ Subu(v0, fp, sp);
+ __ Assert(eq, kUnexpectedStackDepth, v0, Operand(expected_diff));
+ }
+}
void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
Label allocate, done_allocate;
@@ -2097,35 +2104,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();
- __ li(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,
@@ -2138,7 +2116,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr,
// Get the arguments.
Register left = a1;
Register right = a0;
- __ pop(left);
+ PopOperand(left);
__ mov(a0, result_register());
// Perform combined smi check on both operands.
@@ -2227,7 +2205,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
} else {
__ lw(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
@@ -2250,19 +2228,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:
@@ -2274,7 +2252,7 @@ void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) {
__ mov(a0, result_register());
- __ pop(a1);
+ PopOperand(a1);
Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code();
JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
CallIC(code, expr->BinaryOperationFeedbackId());
@@ -2298,10 +2276,10 @@ void FullCodeGenerator::EmitAssignment(Expression* expr,
break;
}
case NAMED_PROPERTY: {
- __ push(result_register()); // Preserve value.
+ PushOperand(result_register()); // Preserve value.
VisitForAccumulatorValue(prop->obj());
__ mov(StoreDescriptor::ReceiverRegister(), result_register());
- __ pop(StoreDescriptor::ValueRegister()); // Restore value.
+ PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
__ li(StoreDescriptor::NameRegister(),
Operand(prop->key()->AsLiteral()->value()));
EmitLoadStoreICSlot(slot);
@@ -2309,7 +2287,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr,
break;
}
case NAMED_SUPER_PROPERTY: {
- __ Push(v0);
+ PushOperand(v0);
VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
VisitForAccumulatorValue(
prop->obj()->AsSuperPropertyReference()->home_object());
@@ -2326,7 +2304,7 @@ void FullCodeGenerator::EmitAssignment(Expression* expr,
break;
}
case KEYED_SUPER_PROPERTY: {
- __ Push(v0);
+ PushOperand(v0);
VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
VisitForStackValue(
prop->obj()->AsSuperPropertyReference()->home_object());
@@ -2346,12 +2324,12 @@ void FullCodeGenerator::EmitAssignment(Expression* expr,
break;
}
case KEYED_PROPERTY: {
- __ push(result_register()); // Preserve value.
+ PushOperand(result_register()); // Preserve value.
VisitForStackValue(prop->obj());
VisitForAccumulatorValue(prop->key());
__ mov(StoreDescriptor::NameRegister(), result_register());
- __ Pop(StoreDescriptor::ValueRegister(),
- StoreDescriptor::ReceiverRegister());
+ PopOperands(StoreDescriptor::ValueRegister(),
+ StoreDescriptor::ReceiverRegister());
EmitLoadStoreICSlot(slot);
Handle<Code> ic =
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
@@ -2491,7 +2469,7 @@ void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
__ mov(StoreDescriptor::ValueRegister(), result_register());
__ li(StoreDescriptor::NameRegister(),
Operand(prop->key()->AsLiteral()->value()));
- __ pop(StoreDescriptor::ReceiverRegister());
+ PopOperand(StoreDescriptor::ReceiverRegister());
EmitLoadStoreICSlot(expr->AssignmentSlot());
CallStoreIC();
@@ -2508,10 +2486,11 @@ void FullCodeGenerator::EmitNamedSuperPropertyStore(Property* prop) {
Literal* key = prop->key()->AsLiteral();
DCHECK(key != NULL);
- __ Push(key->value());
- __ Push(v0);
- __ CallRuntime((is_strict(language_mode()) ? Runtime::kStoreToSuper_Strict
- : Runtime::kStoreToSuper_Sloppy));
+ PushOperand(key->value());
+ PushOperand(v0);
+ CallRuntimeWithOperands(is_strict(language_mode())
+ ? Runtime::kStoreToSuper_Strict
+ : Runtime::kStoreToSuper_Sloppy);
}
@@ -2521,10 +2500,10 @@ void FullCodeGenerator::EmitKeyedSuperPropertyStore(Property* prop) {
// stack : receiver ('this'), home_object, key
DCHECK(prop != NULL);
- __ Push(v0);
- __ CallRuntime((is_strict(language_mode())
- ? Runtime::kStoreKeyedToSuper_Strict
- : Runtime::kStoreKeyedToSuper_Sloppy));
+ PushOperand(v0);
+ CallRuntimeWithOperands(is_strict(language_mode())
+ ? Runtime::kStoreKeyedToSuper_Strict
+ : Runtime::kStoreKeyedToSuper_Sloppy);
}
@@ -2536,7 +2515,8 @@ void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
// - a1 is the key,
// - a2 is the receiver.
__ mov(StoreDescriptor::ValueRegister(), result_register());
- __ Pop(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister());
+ PopOperands(StoreDescriptor::ReceiverRegister(),
+ StoreDescriptor::NameRegister());
DCHECK(StoreDescriptor::ValueRegister().is(a0));
Handle<Code> ic =
@@ -2571,7 +2551,7 @@ void FullCodeGenerator::VisitProperty(Property* expr) {
VisitForStackValue(expr->obj());
VisitForAccumulatorValue(expr->key());
__ Move(LoadDescriptor::NameRegister(), v0);
- __ pop(LoadDescriptor::ReceiverRegister());
+ PopOperand(LoadDescriptor::ReceiverRegister());
EmitKeyedPropertyLoad(expr);
} else {
VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var());
@@ -2607,7 +2587,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(at, Heap::kUndefinedValueRootIndex);
- __ push(at);
+ PushOperand(at);
convert_mode = ConvertReceiverMode::kNullOrUndefined;
} else {
// Load the function from the receiver.
@@ -2618,7 +2598,7 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
// Push the target function under the receiver.
__ lw(at, MemOperand(sp, 0));
- __ push(at);
+ PushOperand(at);
__ sw(v0, MemOperand(sp, kPointerSize));
convert_mode = ConvertReceiverMode::kNotNullOrUndefined;
}
@@ -2642,8 +2622,8 @@ void FullCodeGenerator::EmitSuperCallWithLoadIC(Call* expr) {
VisitForAccumulatorValue(super_ref->home_object());
__ mov(scratch, v0);
VisitForAccumulatorValue(super_ref->this_var());
- __ Push(scratch, v0, v0, scratch);
- __ Push(key->value());
+ PushOperands(scratch, v0, v0, scratch);
+ PushOperand(key->value());
// Stack here:
// - home_object
@@ -2651,7 +2631,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.
__ sw(v0, MemOperand(sp, kPointerSize));
@@ -2680,7 +2660,7 @@ void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr,
// Push the target function under the receiver.
__ lw(at, MemOperand(sp, 0));
- __ push(at);
+ PushOperand(at);
__ sw(v0, MemOperand(sp, kPointerSize));
EmitCall(expr, ConvertReceiverMode::kNotNullOrUndefined);
@@ -2700,7 +2680,7 @@ void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
VisitForAccumulatorValue(super_ref->home_object());
__ Move(scratch, v0);
VisitForAccumulatorValue(super_ref->this_var());
- __ Push(scratch, v0, v0, scratch);
+ PushOperands(scratch, v0, v0, scratch);
VisitForStackValue(prop->key());
// Stack here:
@@ -2709,7 +2689,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.
__ sw(v0, MemOperand(sp, kPointerSize));
@@ -2748,6 +2728,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.
@@ -2795,7 +2776,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
// and the object holding it (returned in v1).
__ Push(callee->name());
__ CallRuntime(Runtime::kLoadLookupSlotForCall);
- __ Push(v0, v1); // Function, receiver.
+ PushOperands(v0, v1); // Function, receiver.
PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS);
// If fast case code has been generated, emit code to push the
@@ -2817,7 +2798,7 @@ void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) {
VisitForStackValue(callee);
// refEnv.WithBaseObject()
__ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
- __ push(a2); // Reserved receiver slot.
+ PushOperand(a2); // Reserved receiver slot.
}
}
@@ -2852,6 +2833,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.
__ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
@@ -2892,6 +2874,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.
__ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
@@ -2912,7 +2895,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
FieldMemOperand(result_register(), HeapObject::kMapOffset));
__ lw(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();
@@ -2934,6 +2917,7 @@ void FullCodeGenerator::EmitSuperConstructorCall(Call* expr) {
__ lw(a1, MemOperand(sp, arg_count * kPointerSize));
__ Call(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
+ OperandStackDepthDecrement(arg_count + 1);
RecordJSReturnSite(expr);
@@ -3156,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, at);
@@ -3193,7 +3177,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, at);
@@ -3267,7 +3251,7 @@ void FullCodeGenerator::EmitStringCharCodeAt(CallRuntime* expr) {
Register index = a0;
Register result = v0;
- __ pop(object);
+ PopOperand(object);
Label need_conversion;
Label index_out_of_range;
@@ -3315,7 +3299,7 @@ void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) {
Register scratch = a3;
Register result = v0;
- __ pop(object);
+ PopOperand(object);
Label need_conversion;
Label index_out_of_range;
@@ -3365,6 +3349,7 @@ void FullCodeGenerator::EmitCall(CallRuntime* expr) {
// Call the target.
__ li(a0, Operand(argc));
__ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
+ OperandStackDepthDecrement(argc + 1);
// Restore context register.
__ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
// Discard the function left on TOS.
@@ -3450,7 +3435,7 @@ void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) {
__ jmp(&done);
__ bind(&runtime);
- __ CallRuntime(Runtime::kCreateIterResultObject);
+ CallRuntimeWithOperands(Runtime::kCreateIterResultObject);
__ bind(&done);
context()->Plug(v0);
@@ -3460,7 +3445,7 @@ void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) {
void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
// Push undefined as the receiver.
__ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
- __ push(v0);
+ PushOperand(v0);
__ LoadNativeContextSlot(expr->context_index(), v0);
}
@@ -3475,6 +3460,7 @@ void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) {
__ li(a0, Operand(arg_count));
__ Call(isolate()->builtins()->Call(ConvertReceiverMode::kNullOrUndefined),
RelocInfo::CODE_TARGET);
+ OperandStackDepthDecrement(arg_count + 1);
}
@@ -3488,7 +3474,7 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
// Push the target function under the receiver.
__ lw(at, MemOperand(sp, 0));
- __ push(at);
+ PushOperand(at);
__ sw(v0, MemOperand(sp, kPointerSize));
// Push the arguments ("left-to-right").
@@ -3524,6 +3510,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(v0);
}
}
@@ -3541,9 +3528,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(v0);
} else if (proxy != NULL) {
Variable* var = proxy->var();
@@ -3609,6 +3596,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(v0, Heap::kTrueValueRootIndex);
@@ -3659,7 +3647,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
// Reserve space for result of postfix operation.
if (expr->is_postfix() && !context()->IsEffect()) {
__ li(at, Operand(Smi::FromInt(0)));
- __ push(at);
+ PushOperand(at);
}
switch (assign_type) {
case NAMED_PROPERTY: {
@@ -3674,10 +3662,10 @@ 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 = a1;
__ lw(scratch, MemOperand(sp, kPointerSize));
- __ Push(scratch, result_register());
+ PushOperands(scratch, result_register());
EmitNamedSuperPropertyLoad(prop);
break;
}
@@ -3690,9 +3678,9 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
const Register scratch1 = t0;
__ Move(scratch, result_register());
VisitForAccumulatorValue(prop->key());
- __ Push(scratch, result_register());
+ PushOperands(scratch, result_register());
__ lw(scratch1, MemOperand(sp, 2 * kPointerSize));
- __ Push(scratch1, scratch, result_register());
+ PushOperands(scratch1, scratch, result_register());
EmitKeyedSuperPropertyLoad(prop);
break;
}
@@ -3778,7 +3766,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
// of the stack.
switch (assign_type) {
case VARIABLE:
- __ push(v0);
+ PushOperand(v0);
break;
case NAMED_PROPERTY:
__ sw(v0, MemOperand(sp, kPointerSize));
@@ -3836,7 +3824,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
__ mov(StoreDescriptor::ValueRegister(), result_register());
__ li(StoreDescriptor::NameRegister(),
Operand(prop->key()->AsLiteral()->value()));
- __ pop(StoreDescriptor::ReceiverRegister());
+ PopOperand(StoreDescriptor::ReceiverRegister());
EmitLoadStoreICSlot(expr->CountSlot());
CallStoreIC();
PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
@@ -3873,8 +3861,8 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
}
case KEYED_PROPERTY: {
__ mov(StoreDescriptor::ValueRegister(), result_register());
- __ Pop(StoreDescriptor::ReceiverRegister(),
- StoreDescriptor::NameRegister());
+ PopOperands(StoreDescriptor::ReceiverRegister(),
+ StoreDescriptor::NameRegister());
Handle<Code> ic =
CodeFactory::KeyedStoreIC(isolate(), language_mode()).code();
EmitLoadStoreICSlot(expr->CountSlot());
@@ -3996,7 +3984,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);
__ LoadRoot(t0, Heap::kTrueValueRootIndex);
Split(eq, v0, Operand(t0), if_true, if_false, fall_through);
@@ -4005,7 +3993,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
case Token::INSTANCEOF: {
VisitForAccumulatorValue(expr->right());
__ mov(a0, result_register());
- __ pop(a1);
+ PopOperand(a1);
InstanceOfStub stub(isolate());
__ CallStub(&stub);
PrepareForBailoutBeforeSplit(expr, false, NULL, NULL);
@@ -4018,7 +4006,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
VisitForAccumulatorValue(expr->right());
Condition cc = CompareIC::ComputeCondition(op);
__ mov(a0, result_register());
- __ pop(a1);
+ PopOperand(a1);
bool inline_smi_code = ShouldInlineSmiCase(op);
JumpPatchSite patch_site(masm_);
@@ -4117,7 +4105,7 @@ void FullCodeGenerator::PushFunctionArgumentForContextAllocation() {
DCHECK(closure_scope->is_function_scope());
__ lw(at, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
}
- __ push(at);
+ PushOperand(at);
}
@@ -4131,7 +4119,7 @@ void FullCodeGenerator::EnterFinallyBlock() {
ExternalReference::address_of_pending_message_obj(isolate());
__ li(at, Operand(pending_message_obj));
__ lw(a1, MemOperand(at));
- __ push(a1);
+ PushOperand(a1);
ClearPendingMessage();
}
@@ -4140,7 +4128,7 @@ void FullCodeGenerator::EnterFinallyBlock() {
void FullCodeGenerator::ExitFinallyBlock() {
DCHECK(!result_register().is(a1));
// Restore pending message from stack.
- __ pop(a1);
+ PopOperand(a1);
ExternalReference pending_message_obj =
ExternalReference::address_of_pending_message_obj(isolate());
__ li(at, Operand(pending_message_obj));
« no previous file with comments | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | src/full-codegen/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698