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

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

Issue 3449004: Cleanup of contexts in the full code generator. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 3 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/ia32/macro-assembler-ia32.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/full-codegen-x64.cc
===================================================================
--- src/x64/full-codegen-x64.cc (revision 5450)
+++ src/x64/full-codegen-x64.cc (working copy)
@@ -237,221 +237,168 @@
}
-void FullCodeGenerator::Apply(Expression::Context context, Register reg) {
- switch (context) {
- case Expression::kUninitialized:
- UNREACHABLE();
+void FullCodeGenerator::EffectContext::Plug(Slot* slot) const {
+}
- case Expression::kEffect:
- // Nothing to do.
- break;
- case Expression::kValue:
- // Move value into place.
- switch (location_) {
- case kAccumulator:
- if (!reg.is(result_register())) __ movq(result_register(), reg);
- break;
- case kStack:
- __ push(reg);
- break;
- }
- break;
+void FullCodeGenerator::AccumulatorValueContext::Plug(Slot* slot) const {
+ MemOperand slot_operand = codegen()->EmitSlotSearch(slot, result_register());
+ __ movq(result_register(), slot_operand);
+}
- case Expression::kTest:
- // For simplicity we always test the accumulator register.
- if (!reg.is(result_register())) __ movq(result_register(), reg);
- DoTest(true_label_, false_label_, fall_through_);
- break;
- }
+
+void FullCodeGenerator::StackValueContext::Plug(Slot* slot) const {
+ MemOperand slot_operand = codegen()->EmitSlotSearch(slot, result_register());
+ __ push(slot_operand);
}
-void FullCodeGenerator::Apply(Expression::Context context, Slot* slot) {
- switch (context) {
- case Expression::kUninitialized:
- UNREACHABLE();
- case Expression::kEffect:
- // Nothing to do.
- break;
- case Expression::kValue: {
- MemOperand slot_operand = EmitSlotSearch(slot, result_register());
- switch (location_) {
- case kAccumulator:
- __ movq(result_register(), slot_operand);
- break;
- case kStack:
- // Memory operands can be pushed directly.
- __ push(slot_operand);
- break;
- }
- break;
- }
+void FullCodeGenerator::TestContext::Plug(Slot* slot) const {
+ codegen()->Move(result_register(), slot);
+ codegen()->DoTest(true_label_, false_label_, fall_through_);
+}
- case Expression::kTest:
- Move(result_register(), slot);
- DoTest(true_label_, false_label_, fall_through_);
- break;
- }
+
+void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {
}
-void FullCodeGenerator::Apply(Expression::Context context, Literal* lit) {
- switch (context) {
- case Expression::kUninitialized:
- UNREACHABLE();
- case Expression::kEffect:
- // Nothing to do.
- break;
- case Expression::kValue:
- switch (location_) {
- case kAccumulator:
- __ Move(result_register(), lit->handle());
- break;
- case kStack:
- __ Push(lit->handle());
- break;
- }
- break;
+void FullCodeGenerator::AccumulatorValueContext::Plug(
+ Heap::RootListIndex index) const {
+ __ LoadRoot(result_register(), index);
+}
- case Expression::kTest:
- __ Move(result_register(), lit->handle());
- DoTest(true_label_, false_label_, fall_through_);
- break;
+
+void FullCodeGenerator::StackValueContext::Plug(
+ Heap::RootListIndex index) const {
+ __ PushRoot(index);
+}
+
+
+void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const {
+ if (index == Heap::kUndefinedValueRootIndex ||
+ index == Heap::kNullValueRootIndex ||
+ index == Heap::kFalseValueRootIndex) {
+ __ jmp(false_label_);
+ } else if (index == Heap::kTrueValueRootIndex) {
+ __ jmp(true_label_);
+ } else {
+ __ LoadRoot(result_register(), index);
+ codegen()->DoTest(true_label_, false_label_, fall_through_);
}
}
-void FullCodeGenerator::ApplyTOS(Expression::Context context) {
- switch (context) {
- case Expression::kUninitialized:
- UNREACHABLE();
+void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {
+}
- case Expression::kEffect:
- __ Drop(1);
- break;
- case Expression::kValue:
- switch (location_) {
- case kAccumulator:
- __ pop(result_register());
- break;
- case kStack:
- break;
- }
- break;
+void FullCodeGenerator::AccumulatorValueContext::Plug(
+ Handle<Object> lit) const {
+ __ Move(result_register(), lit);
+}
- case Expression::kTest:
- __ pop(result_register());
- DoTest(true_label_, false_label_, fall_through_);
- break;
+
+void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
+ __ Push(lit);
+}
+
+
+void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
+ ASSERT(!lit->IsUndetectableObject()); // There are no undetectable literals.
+ if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) {
+ __ jmp(false_label_);
+ } else if (lit->IsTrue() || lit->IsJSObject()) {
+ __ jmp(true_label_);
+ } else if (lit->IsString()) {
+ if (String::cast(*lit)->length() == 0) {
+ __ jmp(false_label_);
+ } else {
+ __ jmp(true_label_);
+ }
+ } else if (lit->IsSmi()) {
+ if (Smi::cast(*lit)->value() == 0) {
+ __ jmp(false_label_);
+ } else {
+ __ jmp(true_label_);
+ }
+ } else {
+ // For simplicity we always test the accumulator register.
+ __ Move(result_register(), lit);
+ codegen()->DoTest(true_label_, false_label_, fall_through_);
}
}
-void FullCodeGenerator::DropAndApply(int count,
- Expression::Context context,
- Register reg) {
+void FullCodeGenerator::StackValueContext::DropAndPlug(int count,
+ Register reg) const {
ASSERT(count > 0);
- ASSERT(!reg.is(rsp));
- switch (context) {
- case Expression::kUninitialized:
- UNREACHABLE();
+ if (count > 1) __ Drop(count - 1);
+ __ movq(Operand(rsp, 0), reg);
+}
- case Expression::kEffect:
- __ Drop(count);
- break;
- case Expression::kValue:
- switch (location_) {
- case kAccumulator:
- __ Drop(count);
- if (!reg.is(result_register())) __ movq(result_register(), reg);
- break;
- case kStack:
- if (count > 1) __ Drop(count - 1);
- __ movq(Operand(rsp, 0), reg);
- break;
- }
- break;
+void FullCodeGenerator::EffectContext::Plug(Label* materialize_true,
+ Label* materialize_false) const {
+ ASSERT_EQ(materialize_true, materialize_false);
+ __ bind(materialize_true);
+}
- case Expression::kTest:
- __ Drop(count);
- if (!reg.is(result_register())) __ movq(result_register(), reg);
- DoTest(true_label_, false_label_, fall_through_);
- break;
- }
+
+void FullCodeGenerator::AccumulatorValueContext::Plug(
+ Label* materialize_true,
+ Label* materialize_false) const {
+ Label done;
+ __ bind(materialize_true);
+ __ Move(result_register(), Factory::true_value());
+ __ jmp(&done);
+ __ bind(materialize_false);
+ __ Move(result_register(), Factory::false_value());
+ __ bind(&done);
}
-void FullCodeGenerator::Apply(Expression::Context context,
- Label* materialize_true,
- Label* materialize_false) {
- switch (context) {
- case Expression::kUninitialized:
+void FullCodeGenerator::StackValueContext::Plug(
+ Label* materialize_true,
+ Label* materialize_false) const {
+ Label done;
+ __ bind(materialize_true);
+ __ Push(Factory::true_value());
+ __ jmp(&done);
+ __ bind(materialize_false);
+ __ Push(Factory::false_value());
+ __ bind(&done);
+}
- case Expression::kEffect:
- ASSERT_EQ(materialize_true, materialize_false);
- __ bind(materialize_true);
- break;
- case Expression::kValue: {
- Label done;
- switch (location_) {
- case kAccumulator:
- __ bind(materialize_true);
- __ Move(result_register(), Factory::true_value());
- __ jmp(&done);
- __ bind(materialize_false);
- __ Move(result_register(), Factory::false_value());
- break;
- case kStack:
- __ bind(materialize_true);
- __ Push(Factory::true_value());
- __ jmp(&done);
- __ bind(materialize_false);
- __ Push(Factory::false_value());
- break;
- }
- __ bind(&done);
- break;
- }
+void FullCodeGenerator::TestContext::Plug(Label* materialize_true,
+ Label* materialize_false) const {
+}
- case Expression::kTest:
- break;
- }
+
+void FullCodeGenerator::EffectContext::Plug(bool flag) const {
}
-// Convert constant control flow (true or false) to the result expected for
-// a given expression context.
-void FullCodeGenerator::Apply(Expression::Context context, bool flag) {
- switch (context) {
- case Expression::kUninitialized:
- UNREACHABLE();
- break;
- case Expression::kEffect:
- break;
- case Expression::kValue: {
- Heap::RootListIndex value_root_index =
- flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
- switch (location_) {
- case kAccumulator:
- __ LoadRoot(result_register(), value_root_index);
- break;
- case kStack:
- __ PushRoot(value_root_index);
- break;
- }
- break;
- }
- case Expression::kTest:
- if (flag) {
- if (true_label_ != fall_through_) __ jmp(true_label_);
- } else {
- if (false_label_ != fall_through_) __ jmp(false_label_);
- }
- break;
+void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const {
+ Heap::RootListIndex value_root_index =
+ flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
+ __ LoadRoot(result_register(), value_root_index);
+}
+
+
+void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
+ Heap::RootListIndex value_root_index =
+ flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex;
+ __ PushRoot(value_root_index);
+}
+
+
+void FullCodeGenerator::TestContext::Plug(bool flag) const {
+ if (flag) {
+ if (true_label_ != fall_through_) __ jmp(true_label_);
+ } else {
+ if (false_label_ != fall_through_) __ jmp(false_label_);
}
}
@@ -555,7 +502,7 @@
__ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
__ movq(Operand(rbp, SlotOffset(slot)), kScratchRegister);
} else if (function != NULL) {
- VisitForValue(function, kAccumulator);
+ VisitForAccumulatorValue(function);
__ movq(Operand(rbp, SlotOffset(slot)), result_register());
}
break;
@@ -577,7 +524,7 @@
__ movq(ContextOperand(rsi, slot->index()), kScratchRegister);
// No write barrier since the hole value is in old space.
} else if (function != NULL) {
- VisitForValue(function, kAccumulator);
+ VisitForAccumulatorValue(function);
__ movq(ContextOperand(rsi, slot->index()), result_register());
int offset = Context::SlotOffset(slot->index());
__ movq(rbx, rsi);
@@ -599,7 +546,7 @@
if (mode == Variable::CONST) {
__ PushRoot(Heap::kTheHoleValueRootIndex);
} else if (function != NULL) {
- VisitForValue(function, kStack);
+ VisitForStackValue(function);
} else {
__ Push(Smi::FromInt(0)); // no initial value!
}
@@ -612,13 +559,13 @@
if (function != NULL || mode == Variable::CONST) {
// We are declaring a function or constant that rewrites to a
// property. Use (keyed) IC to set the initial value.
- VisitForValue(prop->obj(), kStack);
+ VisitForStackValue(prop->obj());
if (function != NULL) {
- VisitForValue(prop->key(), kStack);
- VisitForValue(function, kAccumulator);
+ VisitForStackValue(prop->key());
+ VisitForAccumulatorValue(function);
__ pop(rcx);
} else {
- VisitForValue(prop->key(), kAccumulator);
+ VisitForAccumulatorValue(prop->key());
__ movq(rcx, result_register());
__ LoadRoot(result_register(), Heap::kTheHoleValueRootIndex);
}
@@ -654,7 +601,7 @@
Breakable nested_statement(this, stmt);
SetStatementPosition(stmt);
// Keep the switch value on the stack until a case matches.
- VisitForValue(stmt->tag(), kStack);
+ VisitForStackValue(stmt->tag());
ZoneList<CaseClause*>* clauses = stmt->cases();
CaseClause* default_clause = NULL; // Can occur anywhere in the list.
@@ -674,7 +621,7 @@
next_test.Unuse();
// Compile the label expression.
- VisitForValue(clause->label(), kAccumulator);
+ VisitForAccumulatorValue(clause->label());
// Perform the comparison as if via '==='.
if (ShouldInlineSmiCase(Token::EQ_STRICT)) {
@@ -729,7 +676,7 @@
// Get the object to enumerate over. Both SpiderMonkey and JSC
// ignore null and undefined in contrast to the specification; see
// ECMA-262 section 12.6.4.
- VisitForValue(stmt->enumerable(), kAccumulator);
+ VisitForAccumulatorValue(stmt->enumerable());
__ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
__ j(equal, &exit);
__ CompareRoot(rax, Heap::kNullValueRootIndex);
@@ -867,13 +814,13 @@
__ Push(info);
__ CallRuntime(Runtime::kNewClosure, 2);
}
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
Comment cmnt(masm_, "[ VariableProxy");
- EmitVariableLoad(expr->var(), context_);
+ EmitVariableLoad(expr->var());
}
@@ -1023,8 +970,7 @@
}
-void FullCodeGenerator::EmitVariableLoad(Variable* var,
- Expression::Context context) {
+void FullCodeGenerator::EmitVariableLoad(Variable* var) {
// Four cases: non-this global variables, lookup slots, all other
// types of slots, and parameters that rewrite to explicit property
// accesses on the arguments object.
@@ -1043,7 +989,7 @@
// indicate that the inobject property case was inlined. Ensure there
// is no test rax instruction here.
__ nop();
- Apply(context, rax);
+ context()->Plug(rax);
} else if (slot != NULL && slot->type() == Slot::LOOKUP) {
Label done, slow;
@@ -1059,7 +1005,7 @@
__ CallRuntime(Runtime::kLoadContextSlot, 2);
__ bind(&done);
- Apply(context, rax);
+ context()->Plug(rax);
} else if (slot != NULL) {
Comment cmnt(masm_, (slot->type() == Slot::CONTEXT)
@@ -1075,9 +1021,9 @@
__ j(not_equal, &done);
__ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
__ bind(&done);
- Apply(context, rax);
+ context()->Plug(rax);
} else {
- Apply(context, slot);
+ context()->Plug(slot);
}
} else {
@@ -1109,7 +1055,7 @@
// Notice: We must not have a "test rax, ..." instruction after the
// call. It is treated specially by the LoadIC code.
__ nop();
- Apply(context, rax);
+ context()->Plug(rax);
}
}
@@ -1164,7 +1110,7 @@
__ movq(rdx, FieldOperand(rbx, size - kPointerSize));
__ movq(FieldOperand(rax, size - kPointerSize), rdx);
}
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -1203,7 +1149,7 @@
// Fall through.
case ObjectLiteral::Property::COMPUTED:
if (key->handle()->IsSymbol()) {
- VisitForValue(value, kAccumulator);
+ VisitForAccumulatorValue(value);
__ Move(rcx, key->handle());
__ movq(rdx, Operand(rsp, 0));
Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
@@ -1214,27 +1160,27 @@
// Fall through.
case ObjectLiteral::Property::PROTOTYPE:
__ push(Operand(rsp, 0)); // Duplicate receiver.
- VisitForValue(key, kStack);
- VisitForValue(value, kStack);
+ VisitForStackValue(key);
+ VisitForStackValue(value);
__ CallRuntime(Runtime::kSetProperty, 3);
break;
case ObjectLiteral::Property::SETTER:
case ObjectLiteral::Property::GETTER:
__ push(Operand(rsp, 0)); // Duplicate receiver.
- VisitForValue(key, kStack);
+ VisitForStackValue(key);
__ Push(property->kind() == ObjectLiteral::Property::SETTER ?
Smi::FromInt(1) :
Smi::FromInt(0));
- VisitForValue(value, kStack);
+ VisitForStackValue(value);
__ CallRuntime(Runtime::kDefineAccessor, 4);
break;
}
}
if (result_saved) {
- ApplyTOS(context_);
+ context()->PlugTOS();
} else {
- Apply(context_, rax);
+ context()->Plug(rax);
}
}
@@ -1281,7 +1227,7 @@
__ push(rax);
result_saved = true;
}
- VisitForValue(subexpr, kAccumulator);
+ VisitForAccumulatorValue(subexpr);
// Store the subexpression value in the array's elements.
__ movq(rbx, Operand(rsp, 0)); // Copy of array literal.
@@ -1294,9 +1240,9 @@
}
if (result_saved) {
- ApplyTOS(context_);
+ context()->PlugTOS();
} else {
- Apply(context_, rax);
+ context()->Plug(rax);
}
}
@@ -1329,39 +1275,38 @@
case NAMED_PROPERTY:
if (expr->is_compound()) {
// We need the receiver both on the stack and in the accumulator.
- VisitForValue(property->obj(), kAccumulator);
+ VisitForAccumulatorValue(property->obj());
__ push(result_register());
} else {
- VisitForValue(property->obj(), kStack);
+ VisitForStackValue(property->obj());
}
break;
case KEYED_PROPERTY:
if (expr->is_compound()) {
- VisitForValue(property->obj(), kStack);
- VisitForValue(property->key(), kAccumulator);
+ VisitForStackValue(property->obj());
+ VisitForAccumulatorValue(property->key());
__ movq(rdx, Operand(rsp, 0));
__ push(rax);
} else {
- VisitForValue(property->obj(), kStack);
- VisitForValue(property->key(), kStack);
+ VisitForStackValue(property->obj());
+ VisitForStackValue(property->key());
}
break;
}
if (expr->is_compound()) {
- Location saved_location = location_;
- location_ = kAccumulator;
- switch (assign_type) {
- case VARIABLE:
- EmitVariableLoad(expr->target()->AsVariableProxy()->var(),
- Expression::kValue);
- break;
- case NAMED_PROPERTY:
- EmitNamedPropertyLoad(property);
- break;
- case KEYED_PROPERTY:
- EmitKeyedPropertyLoad(property);
- break;
+ { AccumulatorValueContext context(this);
+ switch (assign_type) {
+ case VARIABLE:
+ EmitVariableLoad(expr->target()->AsVariableProxy()->var());
+ break;
+ case NAMED_PROPERTY:
+ EmitNamedPropertyLoad(property);
+ break;
+ case KEYED_PROPERTY:
+ EmitKeyedPropertyLoad(property);
+ break;
+ }
}
Token::Value op = expr->binary_op();
@@ -1371,28 +1316,26 @@
ASSERT(constant == kRightConstant || constant == kNoConstants);
if (constant == kNoConstants) {
__ push(rax); // Left operand goes on the stack.
- VisitForValue(expr->value(), kAccumulator);
+ VisitForAccumulatorValue(expr->value());
}
OverwriteMode mode = expr->value()->ResultOverwriteAllowed()
? OVERWRITE_RIGHT
: NO_OVERWRITE;
SetSourcePosition(expr->position() + 1);
+ AccumulatorValueContext context(this);
if (ShouldInlineSmiCase(op)) {
EmitInlineSmiBinaryOp(expr,
op,
- Expression::kValue,
mode,
expr->target(),
expr->value(),
constant);
} else {
- EmitBinaryOp(op, Expression::kValue, mode);
+ EmitBinaryOp(op, mode);
}
- location_ = saved_location;
-
} else {
- VisitForValue(expr->value(), kAccumulator);
+ VisitForAccumulatorValue(expr->value());
}
// Record source position before possible IC call.
@@ -1402,8 +1345,7 @@
switch (assign_type) {
case VARIABLE:
EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
- expr->op(),
- context_);
+ expr->op());
break;
case NAMED_PROPERTY:
EmitNamedPropertyAssignment(expr);
@@ -1435,7 +1377,6 @@
void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr,
Token::Value op,
- Expression::Context context,
OverwriteMode mode,
Expression* left,
Expression* right,
@@ -1497,12 +1438,11 @@
}
__ bind(&done);
- Apply(context, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitBinaryOp(Token::Value op,
- Expression::Context context,
OverwriteMode mode) {
GenericBinaryOpStub stub(op, mode, NO_GENERIC_BINARY_FLAGS);
if (stub.ArgsInRegistersSupported()) {
@@ -1512,7 +1452,7 @@
__ push(result_register());
__ CallStub(&stub);
}
- Apply(context, rax);
+ context()->Plug(rax);
}
@@ -1538,12 +1478,13 @@
switch (assign_type) {
case VARIABLE: {
Variable* var = expr->AsVariableProxy()->var();
- EmitVariableAssignment(var, Token::ASSIGN, Expression::kEffect);
+ EffectContext context(this);
+ EmitVariableAssignment(var, Token::ASSIGN);
break;
}
case NAMED_PROPERTY: {
__ push(rax); // Preserve value.
- VisitForValue(prop->obj(), kAccumulator);
+ VisitForAccumulatorValue(prop->obj());
__ movq(rdx, rax);
__ pop(rax); // Restore value.
__ Move(rcx, prop->key()->AsLiteral()->handle());
@@ -1554,8 +1495,8 @@
}
case KEYED_PROPERTY: {
__ push(rax); // Preserve value.
- VisitForValue(prop->obj(), kStack);
- VisitForValue(prop->key(), kAccumulator);
+ VisitForStackValue(prop->obj());
+ VisitForAccumulatorValue(prop->key());
__ movq(rcx, rax);
__ pop(rdx);
__ pop(rax);
@@ -1569,8 +1510,7 @@
void FullCodeGenerator::EmitVariableAssignment(Variable* var,
- Token::Value op,
- Expression::Context context) {
+ Token::Value op) {
// Left-hand sides that rewrite to explicit property accesses do not reach
// here.
ASSERT(var != NULL);
@@ -1640,7 +1580,7 @@
__ bind(&done);
}
- Apply(context, rax);
+ context()->Plug(rax);
}
@@ -1678,9 +1618,9 @@
__ push(Operand(rsp, kPointerSize)); // Receiver is under value.
__ CallRuntime(Runtime::kToFastProperties, 1);
__ pop(rax);
- DropAndApply(1, context_, rax);
+ context()->DropAndPlug(1, rax);
} else {
- Apply(context_, rax);
+ context()->Plug(rax);
}
}
@@ -1722,7 +1662,7 @@
__ pop(rax);
}
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -1731,15 +1671,15 @@
Expression* key = expr->key();
if (key->IsPropertyName()) {
- VisitForValue(expr->obj(), kAccumulator);
+ VisitForAccumulatorValue(expr->obj());
EmitNamedPropertyLoad(expr);
- Apply(context_, rax);
+ context()->Plug(rax);
} else {
- VisitForValue(expr->obj(), kStack);
- VisitForValue(expr->key(), kAccumulator);
+ VisitForStackValue(expr->obj());
+ VisitForAccumulatorValue(expr->key());
__ pop(rdx);
EmitKeyedPropertyLoad(expr);
- Apply(context_, rax);
+ context()->Plug(rax);
}
}
@@ -1751,7 +1691,7 @@
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- VisitForValue(args->at(i), kStack);
+ VisitForStackValue(args->at(i));
}
__ Move(rcx, name);
// Record source position for debugger.
@@ -1763,7 +1703,7 @@
__ Call(ic, mode);
// Restore context register.
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -1774,9 +1714,9 @@
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- VisitForValue(args->at(i), kStack);
+ VisitForStackValue(args->at(i));
}
- VisitForValue(key, kAccumulator);
+ VisitForAccumulatorValue(key);
__ movq(rcx, rax);
// Record source position for debugger.
SetSourcePosition(expr->position());
@@ -1787,7 +1727,7 @@
__ Call(ic, mode);
// Restore context register.
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -1796,7 +1736,7 @@
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- VisitForValue(args->at(i), kStack);
+ VisitForStackValue(args->at(i));
}
// Record source position for debugger.
SetSourcePosition(expr->position());
@@ -1806,7 +1746,7 @@
// Restore context register.
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
// Discard the function left on TOS.
- DropAndApply(1, context_, rax);
+ context()->DropAndPlug(1, rax);
}
@@ -1820,14 +1760,14 @@
// resolve the function we need to call and the receiver of the
// call. The we call the resolved function using the given
// arguments.
- VisitForValue(fun, kStack);
+ VisitForStackValue(fun);
__ PushRoot(Heap::kUndefinedValueRootIndex); // Reserved receiver slot.
// Push the arguments.
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- VisitForValue(args->at(i), kStack);
+ VisitForStackValue(args->at(i));
}
// Push copy of the function - found below the arguments.
@@ -1856,7 +1796,7 @@
__ CallStub(&stub);
// Restore context register.
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
- DropAndApply(1, context_, rax);
+ context()->DropAndPlug(1, rax);
} else if (var != NULL && !var->is_this() && var->is_global()) {
// Call to a global variable.
// Push global object as receiver for the call IC lookup.
@@ -1906,15 +1846,15 @@
Literal* key = prop->key()->AsLiteral();
if (key != NULL && key->handle()->IsSymbol()) {
// Call to a named property, use call IC.
- VisitForValue(prop->obj(), kStack);
+ VisitForStackValue(prop->obj());
EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET);
} else {
// Call to a keyed property.
// For a synthetic property use keyed load IC followed by function call,
// for a regular property use KeyedCallIC.
- VisitForValue(prop->obj(), kStack);
+ VisitForStackValue(prop->obj());
if (prop->is_synthetic()) {
- VisitForValue(prop->key(), kAccumulator);
+ VisitForAccumulatorValue(prop->key());
__ movq(rdx, Operand(rsp, 0));
// Record source code position for IC call.
SetSourcePosition(prop->position());
@@ -1946,7 +1886,7 @@
loop_depth() == 0) {
lit->set_try_full_codegen(true);
}
- VisitForValue(fun, kStack);
+ VisitForStackValue(fun);
// Load global receiver object.
__ movq(rbx, CodeGenerator::GlobalObject());
__ push(FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset));
@@ -1965,13 +1905,13 @@
// Push constructor on the stack. If it's not a function it's used as
// receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
// ignored.
- VisitForValue(expr->expression(), kStack);
+ VisitForStackValue(expr->expression());
// Push the arguments ("left-to-right") on the stack.
ZoneList<Expression*>* args = expr->arguments();
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- VisitForValue(args->at(i), kStack);
+ VisitForStackValue(args->at(i));
}
// Call the construct call builtin that handles allocation and
@@ -1984,59 +1924,59 @@
Handle<Code> construct_builtin(Builtins::builtin(Builtins::JSConstructCall));
__ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ JumpIfSmi(rax, if_true);
__ jmp(if_false);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
Condition positive_smi = __ CheckPositiveSmi(rax);
Split(positive_smi, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitIsObject(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ JumpIfSmi(rax, if_false);
__ CompareRoot(rax, Heap::kNullValueRootIndex);
@@ -2052,41 +1992,41 @@
__ cmpq(rbx, Immediate(LAST_JS_OBJECT_TYPE));
Split(below_equal, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ JumpIfSmi(rax, if_false);
__ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rbx);
Split(above_equal, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ JumpIfSmi(rax, if_false);
__ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
@@ -2094,7 +2034,7 @@
Immediate(1 << Map::kIsUndetectable));
Split(not_zero, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
@@ -2102,80 +2042,80 @@
ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
// Just indicate false, as %_IsStringWrapperSafeForDefaultValueOf() is only
// used in a few functions in runtime.js which should not normally be hit by
// this compiler.
__ jmp(if_false);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ JumpIfSmi(rax, if_false);
__ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
Split(equal, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitIsArray(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ JumpIfSmi(rax, if_false);
__ CmpObjectType(rax, JS_ARRAY_TYPE, rbx);
Split(equal, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitIsRegExp(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ JumpIfSmi(rax, if_false);
__ CmpObjectType(rax, JS_REGEXP_TYPE, rbx);
Split(equal, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
@@ -2187,8 +2127,8 @@
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
// Get the frame pointer for the calling frame.
__ movq(rax, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
@@ -2206,7 +2146,7 @@
Smi::FromInt(StackFrame::CONSTRUCT));
Split(equal, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
@@ -2214,21 +2154,21 @@
ASSERT(args->length() == 2);
// Load the two objects into registers and perform the comparison.
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kAccumulator);
+ VisitForStackValue(args->at(0));
+ VisitForAccumulatorValue(args->at(1));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ pop(rbx);
__ cmpq(rax, rbx);
Split(equal, if_true, if_false, fall_through);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
@@ -2237,12 +2177,12 @@
// ArgumentsAccessStub expects the key in rdx and the formal
// parameter count in rax.
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
__ movq(rdx, rax);
__ Move(rax, Smi::FromInt(scope()->num_parameters()));
ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT);
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2265,7 +2205,7 @@
__ bind(&exit);
if (FLAG_debug_code) __ AbortIfNotSmi(rax);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2273,7 +2213,7 @@
ASSERT(args->length() == 1);
Label done, null, function, non_function_constructor;
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
// If the object is a smi, we return null.
__ JumpIfSmi(rax, &null);
@@ -2319,7 +2259,7 @@
// All done.
__ bind(&done);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2334,14 +2274,14 @@
ASSERT_EQ(args->length(), 3);
#ifdef ENABLE_LOGGING_AND_PROFILING
if (CodeGenerator::ShouldGenerateLog(args->at(0))) {
- VisitForValue(args->at(1), kStack);
- VisitForValue(args->at(2), kStack);
+ VisitForStackValue(args->at(1));
+ VisitForStackValue(args->at(2));
__ CallRuntime(Runtime::kLog, 2);
}
#endif
// Finally, we're expected to leave a value on the top of the stack.
__ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2378,7 +2318,7 @@
__ movsd(FieldOperand(rbx, HeapNumber::kValueOffset), xmm0);
__ movq(rax, rbx);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2386,11 +2326,11 @@
// Load the arguments on the stack and call the stub.
SubStringStub stub;
ASSERT(args->length() == 3);
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kStack);
- VisitForValue(args->at(2), kStack);
+ VisitForStackValue(args->at(0));
+ VisitForStackValue(args->at(1));
+ VisitForStackValue(args->at(2));
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2398,19 +2338,19 @@
// Load the arguments on the stack and call the stub.
RegExpExecStub stub;
ASSERT(args->length() == 4);
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kStack);
- VisitForValue(args->at(2), kStack);
- VisitForValue(args->at(3), kStack);
+ VisitForStackValue(args->at(0));
+ VisitForStackValue(args->at(1));
+ VisitForStackValue(args->at(2));
+ VisitForStackValue(args->at(3));
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitValueOf(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator); // Load the object.
+ VisitForAccumulatorValue(args->at(0)); // Load the object.
Label done;
// If the object is a smi return the object.
@@ -2421,25 +2361,25 @@
__ movq(rax, FieldOperand(rax, JSValue::kValueOffset));
__ bind(&done);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitMathPow(ZoneList<Expression*>* args) {
// Load the arguments on the stack and call the runtime function.
ASSERT(args->length() == 2);
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kStack);
+ VisitForStackValue(args->at(0));
+ VisitForStackValue(args->at(1));
__ CallRuntime(Runtime::kMath_pow, 2);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitSetValueOf(ZoneList<Expression*>* args) {
ASSERT(args->length() == 2);
- VisitForValue(args->at(0), kStack); // Load the object.
- VisitForValue(args->at(1), kAccumulator); // Load the value.
+ VisitForStackValue(args->at(0)); // Load the object.
+ VisitForAccumulatorValue(args->at(1)); // Load the value.
__ pop(rbx); // rax = value. rbx = object.
Label done;
@@ -2458,7 +2398,7 @@
__ RecordWrite(rbx, JSValue::kValueOffset, rdx, rcx);
__ bind(&done);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2466,18 +2406,18 @@
ASSERT_EQ(args->length(), 1);
// Load the argument on the stack and call the stub.
- VisitForValue(args->at(0), kStack);
+ VisitForStackValue(args->at(0));
NumberToStringStub stub;
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitStringCharFromCode(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label done;
StringCharFromCodeGenerator generator(rax, rbx);
@@ -2488,15 +2428,15 @@
generator.GenerateSlow(masm_, call_helper);
__ bind(&done);
- Apply(context_, rbx);
+ context()->Plug(rbx);
}
void FullCodeGenerator::EmitStringCharCodeAt(ZoneList<Expression*>* args) {
ASSERT(args->length() == 2);
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kAccumulator);
+ VisitForStackValue(args->at(0));
+ VisitForAccumulatorValue(args->at(1));
Register object = rbx;
Register index = rax;
@@ -2535,15 +2475,15 @@
generator.GenerateSlow(masm_, call_helper);
__ bind(&done);
- Apply(context_, result);
+ context()->Plug(result);
}
void FullCodeGenerator::EmitStringCharAt(ZoneList<Expression*>* args) {
ASSERT(args->length() == 2);
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kAccumulator);
+ VisitForStackValue(args->at(0));
+ VisitForAccumulatorValue(args->at(1));
Register object = rbx;
Register index = rax;
@@ -2584,31 +2524,31 @@
generator.GenerateSlow(masm_, call_helper);
__ bind(&done);
- Apply(context_, result);
+ context()->Plug(result);
}
void FullCodeGenerator::EmitStringAdd(ZoneList<Expression*>* args) {
ASSERT_EQ(2, args->length());
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kStack);
+ VisitForStackValue(args->at(0));
+ VisitForStackValue(args->at(1));
StringAddStub stub(NO_STRING_ADD_FLAGS);
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitStringCompare(ZoneList<Expression*>* args) {
ASSERT_EQ(2, args->length());
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kStack);
+ VisitForStackValue(args->at(0));
+ VisitForStackValue(args->at(1));
StringCompareStub stub;
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2616,9 +2556,9 @@
// Load the argument on the stack and call the stub.
TranscendentalCacheStub stub(TranscendentalCache::SIN);
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kStack);
+ VisitForStackValue(args->at(0));
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2626,18 +2566,18 @@
// Load the argument on the stack and call the stub.
TranscendentalCacheStub stub(TranscendentalCache::COS);
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kStack);
+ VisitForStackValue(args->at(0));
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitMathSqrt(ZoneList<Expression*>* args) {
// Load the argument on the stack and call the runtime function.
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kStack);
+ VisitForStackValue(args->at(0));
__ CallRuntime(Runtime::kMath_sqrt, 1);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2645,38 +2585,38 @@
ASSERT(args->length() >= 2);
int arg_count = args->length() - 2; // For receiver and function.
- VisitForValue(args->at(0), kStack); // Receiver.
+ VisitForStackValue(args->at(0)); // Receiver.
for (int i = 0; i < arg_count; i++) {
- VisitForValue(args->at(i + 1), kStack);
+ VisitForStackValue(args->at(i + 1));
}
- VisitForValue(args->at(arg_count + 1), kAccumulator); // Function.
+ VisitForAccumulatorValue(args->at(arg_count + 1)); // Function.
// InvokeFunction requires function in rdi. Move it in there.
if (!result_register().is(rdi)) __ movq(rdi, result_register());
ParameterCount count(arg_count);
__ InvokeFunction(rdi, count, CALL_FUNCTION);
__ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitRegExpConstructResult(ZoneList<Expression*>* args) {
ASSERT(args->length() == 3);
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kStack);
- VisitForValue(args->at(2), kStack);
+ VisitForStackValue(args->at(0));
+ VisitForStackValue(args->at(1));
+ VisitForStackValue(args->at(2));
__ CallRuntime(Runtime::kRegExpConstructResult, 3);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) {
ASSERT(args->length() == 3);
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kStack);
- VisitForValue(args->at(2), kStack);
+ VisitForStackValue(args->at(0));
+ VisitForStackValue(args->at(1));
+ VisitForStackValue(args->at(2));
__ CallRuntime(Runtime::kSwapElements, 3);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2691,11 +2631,11 @@
if (jsfunction_result_caches->length() <= cache_id) {
__ Abort("Attempt to use undefined cache.");
__ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
- Apply(context_, rax);
+ context()->Plug(rax);
return;
}
- VisitForValue(args->at(1), kAccumulator);
+ VisitForAccumulatorValue(args->at(1));
Register key = rax;
Register cache = rbx;
@@ -2732,7 +2672,7 @@
__ CallRuntime(Runtime::kGetFromCache, 2);
__ bind(&done);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2743,8 +2683,8 @@
Register left = rbx;
Register tmp = rcx;
- VisitForValue(args->at(0), kStack);
- VisitForValue(args->at(1), kAccumulator);
+ VisitForStackValue(args->at(0));
+ VisitForAccumulatorValue(args->at(1));
__ pop(left);
Label done, fail, ok;
@@ -2770,41 +2710,41 @@
__ Move(rax, Factory::true_value());
__ bind(&done);
- Apply(context_, rax);
+ context()->Plug(rax);
}
void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
__ testl(FieldOperand(rax, String::kHashFieldOffset),
Immediate(String::kContainsCachedArrayIndexMask));
__ j(zero, if_true);
__ jmp(if_false);
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList<Expression*>* args) {
ASSERT(args->length() == 1);
- VisitForValue(args->at(0), kAccumulator);
+ VisitForAccumulatorValue(args->at(0));
__ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
ASSERT(String::kHashShift >= kSmiTagSize);
__ IndexFromHash(rax, rax);
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2828,7 +2768,7 @@
// Push the arguments ("left-to-right").
int arg_count = args->length();
for (int i = 0; i < arg_count; i++) {
- VisitForValue(args->at(i), kStack);
+ VisitForStackValue(args->at(i));
}
if (expr->is_jsruntime()) {
@@ -2842,7 +2782,7 @@
} else {
__ CallRuntime(expr->function(), arg_count);
}
- Apply(context_, rax);
+ context()->Plug(rax);
}
@@ -2856,20 +2796,20 @@
// Result of deleting non-property, non-variable reference is true.
// The subexpression may have side effects.
VisitForEffect(expr->expression());
- Apply(context_, true);
+ context()->Plug(true);
} else if (var != NULL &&
!var->is_global() &&
var->slot() != NULL &&
var->slot()->type() != Slot::LOOKUP) {
// Result of deleting non-global, non-dynamic variables is false.
// The subexpression does not have side effects.
- Apply(context_, false);
+ context()->Plug(false);
} else {
// Property or variable reference. Call the delete builtin with
// object and property name as arguments.
if (prop != NULL) {
- VisitForValue(prop->obj(), kStack);
- VisitForValue(prop->key(), kStack);
+ VisitForStackValue(prop->obj());
+ VisitForStackValue(prop->key());
} else if (var->is_global()) {
__ push(CodeGenerator::GlobalObject());
__ Push(var->name());
@@ -2883,7 +2823,7 @@
__ Push(var->name());
}
__ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
- Apply(context_, rax);
+ context()->Plug(rax);
}
break;
}
@@ -2891,26 +2831,7 @@
case Token::VOID: {
Comment cmnt(masm_, "[ UnaryOperation (VOID)");
VisitForEffect(expr->expression());
- switch (context_) {
- case Expression::kUninitialized:
- UNREACHABLE();
- break;
- case Expression::kEffect:
- break;
- case Expression::kValue:
- switch (location_) {
- case kAccumulator:
- __ LoadRoot(result_register(), Heap::kUndefinedValueRootIndex);
- break;
- case kStack:
- __ PushRoot(Heap::kUndefinedValueRootIndex);
- break;
- }
- break;
- case Expression::kTest:
- __ jmp(false_label_);
- break;
- }
+ context()->Plug(Heap::kUndefinedValueRootIndex);
break;
}
@@ -2921,31 +2842,33 @@
Label* if_false = NULL;
Label* fall_through = NULL;
// Notice that the labels are swapped.
- PrepareTest(&materialize_true, &materialize_false,
- &if_false, &if_true, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_false, &if_true, &fall_through);
VisitForControl(expr->expression(), if_true, if_false, fall_through);
- Apply(context_, if_false, if_true); // Labels swapped.
+ context()->Plug(if_false, if_true); // Labels swapped.
break;
}
case Token::TYPEOF: {
Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)");
- VisitForTypeofValue(expr->expression(), kStack);
+ { StackValueContext context(this);
+ VisitForTypeofValue(expr->expression());
+ }
__ CallRuntime(Runtime::kTypeof, 1);
- Apply(context_, rax);
+ context()->Plug(rax);
break;
}
case Token::ADD: {
Comment cmt(masm_, "[ UnaryOperation (ADD)");
- VisitForValue(expr->expression(), kAccumulator);
+ VisitForAccumulatorValue(expr->expression());
Label no_conversion;
Condition is_smi = masm_->CheckSmi(result_register());
__ j(is_smi, &no_conversion);
__ push(result_register());
__ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
__ bind(&no_conversion);
- Apply(context_, result_register());
+ context()->Plug(result_register());
break;
}
@@ -2957,9 +2880,9 @@
GenericUnaryOpStub stub(Token::SUB, overwrite);
// GenericUnaryOpStub expects the argument to be in the
// accumulator register rax.
- VisitForValue(expr->expression(), kAccumulator);
+ VisitForAccumulatorValue(expr->expression());
__ CallStub(&stub);
- Apply(context_, rax);
+ context()->Plug(rax);
break;
}
@@ -2967,7 +2890,7 @@
Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)");
// The generic unary operation stub expects the argument to be
// in the accumulator register rax.
- VisitForValue(expr->expression(), kAccumulator);
+ VisitForAccumulatorValue(expr->expression());
Label done;
if (ShouldInlineSmiCase(expr->op())) {
Label call_stub;
@@ -2982,7 +2905,7 @@
GenericUnaryOpStub stub(Token::BIT_NOT, mode);
__ CallStub(&stub);
__ bind(&done);
- Apply(context_, rax);
+ context()->Plug(rax);
break;
}
@@ -3018,23 +2941,20 @@
// Evaluate expression and get value.
if (assign_type == VARIABLE) {
ASSERT(expr->expression()->AsVariableProxy()->var() != NULL);
- Location saved_location = location_;
- location_ = kAccumulator;
- EmitVariableLoad(expr->expression()->AsVariableProxy()->var(),
- Expression::kValue);
- location_ = saved_location;
+ AccumulatorValueContext context(this);
+ EmitVariableLoad(expr->expression()->AsVariableProxy()->var());
} else {
// Reserve space for result of postfix operation.
- if (expr->is_postfix() && context_ != Expression::kEffect) {
+ if (expr->is_postfix() && !context()->IsEffect()) {
__ Push(Smi::FromInt(0));
}
if (assign_type == NAMED_PROPERTY) {
- VisitForValue(prop->obj(), kAccumulator);
+ VisitForAccumulatorValue(prop->obj());
__ push(rax); // Copy of receiver, needed for later store.
EmitNamedPropertyLoad(prop);
} else {
- VisitForValue(prop->obj(), kStack);
- VisitForValue(prop->key(), kAccumulator);
+ VisitForStackValue(prop->obj());
+ VisitForAccumulatorValue(prop->key());
__ movq(rdx, Operand(rsp, 0)); // Leave receiver on stack
__ push(rax); // Copy of key, needed for later store.
EmitKeyedPropertyLoad(prop);
@@ -3052,29 +2972,21 @@
// Save result for postfix expressions.
if (expr->is_postfix()) {
- switch (context_) {
- case Expression::kUninitialized:
- UNREACHABLE();
- case Expression::kEffect:
- // Do not save result.
- break;
- case Expression::kValue:
- case Expression::kTest:
- // Save the result on the stack. If we have a named or keyed property
- // we store the result under the receiver that is currently on top
- // of the stack.
- switch (assign_type) {
- case VARIABLE:
- __ push(rax);
- break;
- case NAMED_PROPERTY:
- __ movq(Operand(rsp, kPointerSize), rax);
- break;
- case KEYED_PROPERTY:
- __ movq(Operand(rsp, 2 * kPointerSize), rax);
- break;
- }
- break;
+ if (!context()->IsEffect()) {
+ // Save the result on the stack. If we have a named or keyed property
+ // we store the result under the receiver that is currently on top
+ // of the stack.
+ switch (assign_type) {
+ case VARIABLE:
+ __ push(rax);
+ break;
+ case NAMED_PROPERTY:
+ __ movq(Operand(rsp, kPointerSize), rax);
+ break;
+ case KEYED_PROPERTY:
+ __ movq(Operand(rsp, 2 * kPointerSize), rax);
+ break;
+ }
}
}
@@ -3111,19 +3023,19 @@
case VARIABLE:
if (expr->is_postfix()) {
// Perform the assignment as if via '='.
- EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
- Token::ASSIGN,
- Expression::kEffect);
+ { EffectContext context(this);
+ EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
+ Token::ASSIGN);
+ }
// For all contexts except kEffect: We have the result on
// top of the stack.
- if (context_ != Expression::kEffect) {
- ApplyTOS(context_);
+ if (!context()->IsEffect()) {
+ context()->PlugTOS();
}
} else {
// Perform the assignment as if via '='.
EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
- Token::ASSIGN,
- context_);
+ Token::ASSIGN);
}
break;
case NAMED_PROPERTY: {
@@ -3135,11 +3047,11 @@
// site for it to patch.
__ nop();
if (expr->is_postfix()) {
- if (context_ != Expression::kEffect) {
- ApplyTOS(context_);
+ if (!context()->IsEffect()) {
+ context()->PlugTOS();
}
} else {
- Apply(context_, rax);
+ context()->Plug(rax);
}
break;
}
@@ -3152,11 +3064,11 @@
// site for it to patch.
__ nop();
if (expr->is_postfix()) {
- if (context_ != Expression::kEffect) {
- ApplyTOS(context_);
+ if (!context()->IsEffect()) {
+ context()->PlugTOS();
}
} else {
- Apply(context_, rax);
+ context()->Plug(rax);
}
break;
}
@@ -3164,8 +3076,11 @@
}
-void FullCodeGenerator::VisitForTypeofValue(Expression* expr, Location where) {
+void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
VariableProxy* proxy = expr->AsVariableProxy();
+ ASSERT(!context()->IsEffect());
+ ASSERT(!context()->IsTest());
+
if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) {
Comment cmnt(masm_, "Global variable");
__ Move(rcx, proxy->name());
@@ -3174,7 +3089,7 @@
// Use a regular load, not a contextual load, to avoid a reference
// error.
__ Call(ic, RelocInfo::CODE_TARGET);
- if (where == kStack) __ push(rax);
+ context()->Plug(rax);
} else if (proxy != NULL &&
proxy->var()->slot() != NULL &&
proxy->var()->slot()->type() == Slot::LOOKUP) {
@@ -3191,10 +3106,10 @@
__ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2);
__ bind(&done);
- if (where == kStack) __ push(rax);
+ context()->Plug(rax);
} else {
// This expression cannot throw a reference error at the top level.
- VisitForValue(expr, where);
+ Visit(expr);
}
}
@@ -3216,7 +3131,10 @@
if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
Handle<String> check = Handle<String>::cast(right_literal_value);
- VisitForTypeofValue(left_unary->expression(), kAccumulator);
+ { AccumulatorValueContext context(this);
+ VisitForTypeofValue(left_unary->expression());
+ }
+
if (check->Equals(Heap::number_symbol())) {
Condition is_smi = masm_->CheckSmi(rax);
__ j(is_smi, if_true);
@@ -3291,8 +3209,8 @@
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
// First we try a fast inlined version of the compare when one of
// the operands is a literal.
@@ -3300,21 +3218,21 @@
Expression* left = expr->left();
Expression* right = expr->right();
if (TryLiteralCompare(op, left, right, if_true, if_false, fall_through)) {
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
return;
}
- VisitForValue(expr->left(), kStack);
+ VisitForStackValue(expr->left());
switch (op) {
case Token::IN:
- VisitForValue(expr->right(), kStack);
+ VisitForStackValue(expr->right());
__ InvokeBuiltin(Builtins::IN, CALL_FUNCTION);
__ CompareRoot(rax, Heap::kTrueValueRootIndex);
Split(equal, if_true, if_false, fall_through);
break;
case Token::INSTANCEOF: {
- VisitForValue(expr->right(), kStack);
+ VisitForStackValue(expr->right());
InstanceofStub stub;
__ CallStub(&stub);
__ testq(rax, rax);
@@ -3324,7 +3242,7 @@
}
default: {
- VisitForValue(expr->right(), kAccumulator);
+ VisitForAccumulatorValue(expr->right());
Condition cc = no_condition;
bool strict = false;
switch (op) {
@@ -3378,7 +3296,7 @@
// Convert the result of the comparison into one expected for this
// expression's context.
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
@@ -3388,10 +3306,10 @@
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
- PrepareTest(&materialize_true, &materialize_false,
- &if_true, &if_false, &fall_through);
+ context()->PrepareTest(&materialize_true, &materialize_false,
+ &if_true, &if_false, &fall_through);
- VisitForValue(expr->expression(), kAccumulator);
+ VisitForAccumulatorValue(expr->expression());
__ CompareRoot(rax, Heap::kNullValueRootIndex);
if (expr->is_strict()) {
Split(equal, if_true, if_false, fall_through);
@@ -3407,13 +3325,13 @@
Immediate(1 << Map::kIsUndetectable));
Split(not_zero, if_true, if_false, fall_through);
}
- Apply(context_, if_true, if_false);
+ context()->Plug(if_true, if_false);
}
void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) {
__ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
- Apply(context_, rax);
+ context()->Plug(rax);
}
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698