| Index: src/arm/full-codegen-arm.cc
|
| ===================================================================
|
| --- src/arm/full-codegen-arm.cc (revision 5450)
|
| +++ src/arm/full-codegen-arm.cc (working copy)
|
| @@ -253,205 +253,176 @@
|
| }
|
|
|
|
|
| -void FullCodeGenerator::Apply(Expression::Context context, Register reg) {
|
| - switch (context) {
|
| - case Expression::kUninitialized:
|
| - UNREACHABLE();
|
| +void FullCodeGenerator::EffectContext::Plug(Slot* slot) const {
|
| + // Nothing to do.
|
| +}
|
|
|
| - case Expression::kEffect:
|
| - // Nothing to do.
|
| - break;
|
|
|
| - case Expression::kValue:
|
| - // Move value into place.
|
| - switch (location_) {
|
| - case kAccumulator:
|
| - if (!reg.is(result_register())) __ mov(result_register(), reg);
|
| - break;
|
| - case kStack:
|
| - __ push(reg);
|
| - break;
|
| - }
|
| - break;
|
| +void FullCodeGenerator::AccumulatorValueContext::Plug(Slot* slot) const {
|
| + codegen()->Move(result_register(), slot);
|
| +}
|
|
|
| - case Expression::kTest:
|
| - // For simplicity we always test the accumulator register.
|
| - if (!reg.is(result_register())) __ mov(result_register(), reg);
|
| - DoTest(true_label_, false_label_, fall_through_);
|
| - break;
|
| - }
|
| +
|
| +void FullCodeGenerator::StackValueContext::Plug(Slot* slot) const {
|
| + codegen()->Move(result_register(), slot);
|
| + __ push(result_register());
|
| }
|
|
|
|
|
| -void FullCodeGenerator::Apply(Expression::Context context, Slot* slot) {
|
| - switch (context) {
|
| - case Expression::kUninitialized:
|
| - UNREACHABLE();
|
| - case Expression::kEffect:
|
| - // Nothing to do.
|
| - break;
|
| - case Expression::kValue:
|
| - case Expression::kTest:
|
| - // On ARM we have to move the value into a register to do anything
|
| - // with it.
|
| - Move(result_register(), slot);
|
| - Apply(context, result_register());
|
| - break;
|
| - }
|
| +void FullCodeGenerator::TestContext::Plug(Slot* slot) const {
|
| + // For simplicity we always test the accumulator register.
|
| + codegen()->Move(result_register(), slot);
|
| + codegen()->DoTest(true_label_, false_label_, fall_through_);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::Apply(Expression::Context context, Literal* lit) {
|
| - switch (context) {
|
| - case Expression::kUninitialized:
|
| - UNREACHABLE();
|
| - case Expression::kEffect:
|
| - break;
|
| - // Nothing to do.
|
| - case Expression::kValue:
|
| - case Expression::kTest:
|
| - // On ARM we have to move the value into a register to do anything
|
| - // with it.
|
| - __ mov(result_register(), Operand(lit->handle()));
|
| - Apply(context, result_register());
|
| - break;
|
| +void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {
|
| +}
|
| +
|
| +
|
| +void FullCodeGenerator::AccumulatorValueContext::Plug(
|
| + Heap::RootListIndex index) const {
|
| + __ LoadRoot(result_register(), index);
|
| +}
|
| +
|
| +
|
| +void FullCodeGenerator::StackValueContext::Plug(
|
| + Heap::RootListIndex index) const {
|
| + __ LoadRoot(result_register(), index);
|
| + __ push(result_register());
|
| +}
|
| +
|
| +
|
| +void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const {
|
| + if (index == Heap::kUndefinedValueRootIndex ||
|
| + index == Heap::kNullValueRootIndex ||
|
| + index == Heap::kFalseValueRootIndex) {
|
| + __ b(false_label_);
|
| + } else if (index == Heap::kTrueValueRootIndex) {
|
| + __ b(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 {
|
| + // Nothing to do.
|
| +}
|
|
|
| - 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 {
|
| + __ mov(result_register(), Operand(lit));
|
| +}
|
|
|
| - case Expression::kTest:
|
| - __ pop(result_register());
|
| - DoTest(true_label_, false_label_, fall_through_);
|
| - break;
|
| +
|
| +void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
|
| + // Immediates can be pushed directly.
|
| + __ mov(result_register(), Operand(lit));
|
| + __ push(result_register());
|
| +}
|
| +
|
| +
|
| +void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
| + ASSERT(!lit->IsUndetectableObject()); // There are no undetectable literals.
|
| + if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) {
|
| + __ b(false_label_);
|
| + } else if (lit->IsTrue() || lit->IsJSObject()) {
|
| + __ b(true_label_);
|
| + } else if (lit->IsString()) {
|
| + if (String::cast(*lit)->length() == 0) {
|
| + __ b(false_label_);
|
| + } else {
|
| + __ b(true_label_);
|
| + }
|
| + } else if (lit->IsSmi()) {
|
| + if (Smi::cast(*lit)->value() == 0) {
|
| + __ b(false_label_);
|
| + } else {
|
| + __ b(true_label_);
|
| + }
|
| + } else {
|
| + // For simplicity we always test the accumulator register.
|
| + __ mov(result_register(), Operand(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(sp));
|
| - switch (context) {
|
| - case Expression::kUninitialized:
|
| - UNREACHABLE();
|
| + if (count > 1) __ Drop(count - 1);
|
| + __ str(reg, MemOperand(sp, 0));
|
| +}
|
|
|
| - case Expression::kEffect:
|
| - __ Drop(count);
|
| - break;
|
|
|
| - case Expression::kValue:
|
| - switch (location_) {
|
| - case kAccumulator:
|
| - __ Drop(count);
|
| - if (!reg.is(result_register())) __ mov(result_register(), reg);
|
| - break;
|
| - case kStack:
|
| - if (count > 1) __ Drop(count - 1);
|
| - __ str(reg, MemOperand(sp));
|
| - 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())) __ mov(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);
|
| + __ LoadRoot(result_register(), Heap::kTrueValueRootIndex);
|
| + __ jmp(&done);
|
| + __ bind(materialize_false);
|
| + __ LoadRoot(result_register(), Heap::kFalseValueRootIndex);
|
| + __ 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);
|
| + __ LoadRoot(ip, Heap::kTrueValueRootIndex);
|
| + __ push(ip);
|
| + __ jmp(&done);
|
| + __ bind(materialize_false);
|
| + __ LoadRoot(ip, Heap::kFalseValueRootIndex);
|
| + __ push(ip);
|
| + __ 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);
|
| - __ LoadRoot(result_register(), Heap::kTrueValueRootIndex);
|
| - __ jmp(&done);
|
| - __ bind(materialize_false);
|
| - __ LoadRoot(result_register(), Heap::kFalseValueRootIndex);
|
| - break;
|
| - case kStack:
|
| - __ bind(materialize_true);
|
| - __ LoadRoot(ip, Heap::kTrueValueRootIndex);
|
| - __ push(ip);
|
| - __ jmp(&done);
|
| - __ bind(materialize_false);
|
| - __ LoadRoot(ip, Heap::kFalseValueRootIndex);
|
| - __ push(ip);
|
| - 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:
|
| - __ LoadRoot(ip, value_root_index);
|
| - __ push(ip);
|
| - break;
|
| - }
|
| - break;
|
| - }
|
| - case Expression::kTest:
|
| - if (flag) {
|
| - if (true_label_ != fall_through_) __ b(true_label_);
|
| - } else {
|
| - if (false_label_ != fall_through_) __ b(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;
|
| + __ LoadRoot(ip, value_root_index);
|
| + __ push(ip);
|
| +}
|
| +
|
| +
|
| +void FullCodeGenerator::TestContext::Plug(bool flag) const {
|
| + if (flag) {
|
| + if (true_label_ != fall_through_) __ b(true_label_);
|
| + } else {
|
| + if (false_label_ != fall_through_) __ b(false_label_);
|
| }
|
| }
|
|
|
| @@ -544,7 +515,7 @@
|
| __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
|
| __ str(ip, MemOperand(fp, SlotOffset(slot)));
|
| } else if (function != NULL) {
|
| - VisitForValue(function, kAccumulator);
|
| + VisitForAccumulatorValue(function);
|
| __ str(result_register(), MemOperand(fp, SlotOffset(slot)));
|
| }
|
| break;
|
| @@ -566,7 +537,7 @@
|
| __ str(ip, ContextOperand(cp, slot->index()));
|
| // No write barrier since the_hole_value is in old space.
|
| } else if (function != NULL) {
|
| - VisitForValue(function, kAccumulator);
|
| + VisitForAccumulatorValue(function);
|
| __ str(result_register(), ContextOperand(cp, slot->index()));
|
| int offset = Context::SlotOffset(slot->index());
|
| // We know that we have written a function, which is not a smi.
|
| @@ -593,7 +564,7 @@
|
| } else if (function != NULL) {
|
| __ Push(cp, r2, r1);
|
| // Push initial value for function declaration.
|
| - VisitForValue(function, kStack);
|
| + VisitForStackValue(function);
|
| } else {
|
| __ mov(r0, Operand(Smi::FromInt(0))); // No initial value!
|
| __ Push(cp, r2, r1, r0);
|
| @@ -607,13 +578,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(r1); // Key.
|
| } else {
|
| - VisitForValue(prop->key(), kAccumulator);
|
| + VisitForAccumulatorValue(prop->key());
|
| __ mov(r1, result_register()); // Key.
|
| __ LoadRoot(result_register(), Heap::kTheHoleValueRootIndex);
|
| }
|
| @@ -648,7 +619,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.
|
| @@ -668,7 +639,7 @@
|
| next_test.Unuse();
|
|
|
| // Compile the label expression.
|
| - VisitForValue(clause->label(), kAccumulator);
|
| + VisitForAccumulatorValue(clause->label());
|
|
|
| // Perform the comparison as if via '==='.
|
| __ ldr(r1, MemOperand(sp, 0)); // Switch value.
|
| @@ -725,7 +696,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());
|
| __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
|
| __ cmp(r0, ip);
|
| __ b(eq, &exit);
|
| @@ -868,13 +839,13 @@
|
| __ Push(cp, r0);
|
| __ CallRuntime(Runtime::kNewClosure, 2);
|
| }
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
|
| Comment cmnt(masm_, "[ VariableProxy");
|
| - EmitVariableLoad(expr->var(), context_);
|
| + EmitVariableLoad(expr->var());
|
| }
|
|
|
|
|
| @@ -1022,8 +993,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.
|
| @@ -1038,7 +1008,7 @@
|
| __ mov(r2, Operand(var->name()));
|
| Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
|
| __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT);
|
| - Apply(context, r0);
|
| + context()->Plug(r0);
|
|
|
| } else if (slot != NULL && slot->type() == Slot::LOOKUP) {
|
| Label done, slow;
|
| @@ -1054,24 +1024,24 @@
|
| __ CallRuntime(Runtime::kLoadContextSlot, 2);
|
| __ bind(&done);
|
|
|
| - Apply(context, r0);
|
| + context()->Plug(r0);
|
|
|
| } else if (slot != NULL) {
|
| Comment cmnt(masm_, (slot->type() == Slot::CONTEXT)
|
| ? "Context slot"
|
| : "Stack slot");
|
| if (var->mode() == Variable::CONST) {
|
| - // Constants may be the hole value if they have not been initialized.
|
| - // Unhole them.
|
| - MemOperand slot_operand = EmitSlotSearch(slot, r0);
|
| - __ ldr(r0, slot_operand);
|
| - __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
|
| - __ cmp(r0, ip);
|
| - __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq);
|
| - Apply(context, r0);
|
| - } else {
|
| - Apply(context, slot);
|
| - }
|
| + // Constants may be the hole value if they have not been initialized.
|
| + // Unhole them.
|
| + MemOperand slot_operand = EmitSlotSearch(slot, r0);
|
| + __ ldr(r0, slot_operand);
|
| + __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
|
| + __ cmp(r0, ip);
|
| + __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq);
|
| + context()->Plug(r0);
|
| + } else {
|
| + context()->Plug(slot);
|
| + }
|
| } else {
|
| Comment cmnt(masm_, "Rewritten parameter");
|
| ASSERT_NOT_NULL(property);
|
| @@ -1097,7 +1067,7 @@
|
| // Call keyed load IC. It has arguments key and receiver in r0 and r1.
|
| Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize));
|
| __ Call(ic, RelocInfo::CODE_TARGET);
|
| - Apply(context, r0);
|
| + context()->Plug(r0);
|
| }
|
| }
|
|
|
| @@ -1141,7 +1111,7 @@
|
| // r2: temp.
|
| __ pop(r1);
|
| __ CopyFields(r0, r1, r2.bit(), size / kPointerSize);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -1181,7 +1151,7 @@
|
| // Fall through.
|
| case ObjectLiteral::Property::COMPUTED:
|
| if (key->handle()->IsSymbol()) {
|
| - VisitForValue(value, kAccumulator);
|
| + VisitForAccumulatorValue(value);
|
| __ mov(r2, Operand(key->handle()));
|
| __ ldr(r1, MemOperand(sp));
|
| Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
|
| @@ -1193,8 +1163,8 @@
|
| // Duplicate receiver on stack.
|
| __ ldr(r0, MemOperand(sp));
|
| __ push(r0);
|
| - VisitForValue(key, kStack);
|
| - VisitForValue(value, kStack);
|
| + VisitForStackValue(key);
|
| + VisitForStackValue(value);
|
| __ CallRuntime(Runtime::kSetProperty, 3);
|
| break;
|
| case ObjectLiteral::Property::GETTER:
|
| @@ -1202,21 +1172,21 @@
|
| // Duplicate receiver on stack.
|
| __ ldr(r0, MemOperand(sp));
|
| __ push(r0);
|
| - VisitForValue(key, kStack);
|
| + VisitForStackValue(key);
|
| __ mov(r1, Operand(property->kind() == ObjectLiteral::Property::SETTER ?
|
| Smi::FromInt(1) :
|
| Smi::FromInt(0)));
|
| __ push(r1);
|
| - VisitForValue(value, kStack);
|
| + VisitForStackValue(value);
|
| __ CallRuntime(Runtime::kDefineAccessor, 4);
|
| break;
|
| }
|
| }
|
|
|
| if (result_saved) {
|
| - ApplyTOS(context_);
|
| + context()->PlugTOS();
|
| } else {
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| }
|
|
|
| @@ -1264,7 +1234,7 @@
|
| __ push(r0);
|
| result_saved = true;
|
| }
|
| - VisitForValue(subexpr, kAccumulator);
|
| + VisitForAccumulatorValue(subexpr);
|
|
|
| // Store the subexpression value in the array's elements.
|
| __ ldr(r1, MemOperand(sp)); // Copy of array literal.
|
| @@ -1278,9 +1248,9 @@
|
| }
|
|
|
| if (result_saved) {
|
| - ApplyTOS(context_);
|
| + context()->PlugTOS();
|
| } else {
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| }
|
|
|
| @@ -1313,39 +1283,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());
|
| __ ldr(r1, MemOperand(sp, 0));
|
| __ push(r0);
|
| } 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();
|
| @@ -1355,28 +1324,26 @@
|
| ASSERT(constant == kRightConstant || constant == kNoConstants);
|
| if (constant == kNoConstants) {
|
| __ push(r0); // 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.
|
| @@ -1386,8 +1353,7 @@
|
| switch (assign_type) {
|
| case VARIABLE:
|
| EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
|
| - expr->op(),
|
| - context_);
|
| + expr->op());
|
| break;
|
| case NAMED_PROPERTY:
|
| EmitNamedPropertyAssignment(expr);
|
| @@ -1419,23 +1385,21 @@
|
|
|
| void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr,
|
| Token::Value op,
|
| - Expression::Context context,
|
| OverwriteMode mode,
|
| Expression* left,
|
| Expression* right,
|
| ConstantOperand constant) {
|
| ASSERT(constant == kNoConstants); // Only handled case.
|
| - EmitBinaryOp(op, context, mode);
|
| + EmitBinaryOp(op, mode);
|
| }
|
|
|
|
|
| void FullCodeGenerator::EmitBinaryOp(Token::Value op,
|
| - Expression::Context context,
|
| OverwriteMode mode) {
|
| __ pop(r1);
|
| GenericBinaryOpStub stub(op, mode, r1, r0);
|
| __ CallStub(&stub);
|
| - Apply(context, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -1461,12 +1425,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(r0); // Preserve value.
|
| - VisitForValue(prop->obj(), kAccumulator);
|
| + VisitForAccumulatorValue(prop->obj());
|
| __ mov(r1, r0);
|
| __ pop(r0); // Restore value.
|
| __ mov(r2, Operand(prop->key()->AsLiteral()->handle()));
|
| @@ -1476,8 +1441,8 @@
|
| }
|
| case KEYED_PROPERTY: {
|
| __ push(r0); // Preserve value.
|
| - VisitForValue(prop->obj(), kStack);
|
| - VisitForValue(prop->key(), kAccumulator);
|
| + VisitForStackValue(prop->obj());
|
| + VisitForAccumulatorValue(prop->key());
|
| __ mov(r1, r0);
|
| __ pop(r2);
|
| __ pop(r0); // Restore value.
|
| @@ -1490,8 +1455,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);
|
| @@ -1561,7 +1525,7 @@
|
| __ bind(&done);
|
| }
|
|
|
| - Apply(context, result_register());
|
| + context()->Plug(result_register());
|
| }
|
|
|
|
|
| @@ -1604,9 +1568,9 @@
|
| __ push(ip);
|
| __ CallRuntime(Runtime::kToFastProperties, 1);
|
| __ pop(r0);
|
| - DropAndApply(1, context_, r0);
|
| + context()->DropAndPlug(1, r0);
|
| } else {
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| }
|
|
|
| @@ -1648,9 +1612,9 @@
|
| __ push(ip);
|
| __ CallRuntime(Runtime::kToFastProperties, 1);
|
| __ pop(r0);
|
| - DropAndApply(1, context_, r0);
|
| + context()->DropAndPlug(1, r0);
|
| } else {
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| }
|
|
|
| @@ -1660,15 +1624,15 @@
|
| Expression* key = expr->key();
|
|
|
| if (key->IsPropertyName()) {
|
| - VisitForValue(expr->obj(), kAccumulator);
|
| + VisitForAccumulatorValue(expr->obj());
|
| EmitNamedPropertyLoad(expr);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| } else {
|
| - VisitForValue(expr->obj(), kStack);
|
| - VisitForValue(expr->key(), kAccumulator);
|
| + VisitForStackValue(expr->obj());
|
| + VisitForAccumulatorValue(expr->key());
|
| __ pop(r1);
|
| EmitKeyedPropertyLoad(expr);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| }
|
|
|
| @@ -1679,7 +1643,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));
|
| }
|
| __ mov(r2, Operand(name));
|
| // Record source position for debugger.
|
| @@ -1690,7 +1654,7 @@
|
| __ Call(ic, mode);
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -1701,9 +1665,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);
|
| __ mov(r2, r0);
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| @@ -1714,7 +1678,7 @@
|
| __ Call(ic, mode);
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -1723,7 +1687,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());
|
| @@ -1732,7 +1696,7 @@
|
| __ CallStub(&stub);
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - DropAndApply(1, context_, r0);
|
| + context()->DropAndPlug(1, r0);
|
| }
|
|
|
|
|
| @@ -1746,7 +1710,7 @@
|
| // resolve the function we need to call and the receiver of the
|
| // call. Then we call the resolved function using the given
|
| // arguments.
|
| - VisitForValue(fun, kStack);
|
| + VisitForStackValue(fun);
|
| __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
|
| __ push(r2); // Reserved receiver slot.
|
|
|
| @@ -1754,7 +1718,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));
|
| }
|
|
|
| // Push copy of the function - found below the arguments.
|
| @@ -1786,7 +1750,7 @@
|
| __ CallStub(&stub);
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - DropAndApply(1, context_, r0);
|
| + context()->DropAndPlug(1, r0);
|
| } else if (var != NULL && !var->is_this() && var->is_global()) {
|
| // Push global object as receiver for the call IC.
|
| __ ldr(r0, CodeGenerator::GlobalObject());
|
| @@ -1805,7 +1769,7 @@
|
| &done);
|
|
|
| __ bind(&slow);
|
| - // Call the runtime to find the function to call (returned in eax)
|
| + // Call the runtime to find the function to call (returned in r0)
|
| // and the object holding it (returned in edx).
|
| __ push(context_register());
|
| __ mov(r2, Operand(var->name()));
|
| @@ -1836,15 +1800,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 keyed CallIC.
|
| - VisitForValue(prop->obj(), kStack);
|
| + VisitForStackValue(prop->obj());
|
| if (prop->is_synthetic()) {
|
| - VisitForValue(prop->key(), kAccumulator);
|
| + VisitForAccumulatorValue(prop->key());
|
| // Record source code position for IC call.
|
| SetSourcePosition(prop->position());
|
| __ pop(r1); // We do not need to keep the receiver.
|
| @@ -1869,7 +1833,7 @@
|
| loop_depth() == 0) {
|
| lit->set_try_full_codegen(true);
|
| }
|
| - VisitForValue(fun, kStack);
|
| + VisitForStackValue(fun);
|
| // Load global receiver object.
|
| __ ldr(r1, CodeGenerator::GlobalObject());
|
| __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset));
|
| @@ -1889,13 +1853,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
|
| @@ -1908,59 +1872,59 @@
|
|
|
| Handle<Code> construct_builtin(Builtins::builtin(Builtins::JSConstructCall));
|
| __ Call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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);
|
|
|
| __ BranchOnSmi(r0, if_true);
|
| __ b(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);
|
|
|
| __ tst(r0, Operand(kSmiTagMask | 0x80000000));
|
| Split(eq, 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);
|
|
|
| __ BranchOnSmi(r0, if_false);
|
| __ LoadRoot(ip, Heap::kNullValueRootIndex);
|
| @@ -1977,41 +1941,41 @@
|
| __ cmp(r1, Operand(LAST_JS_OBJECT_TYPE));
|
| Split(le, 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);
|
|
|
| __ BranchOnSmi(r0, if_false);
|
| __ CompareObjectType(r0, r1, r1, FIRST_JS_OBJECT_TYPE);
|
| Split(ge, 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);
|
|
|
| __ BranchOnSmi(r0, if_false);
|
| __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset));
|
| @@ -2019,7 +1983,7 @@
|
| __ tst(r1, Operand(1 << Map::kIsUndetectable));
|
| Split(ne, if_true, if_false, fall_through);
|
|
|
| - Apply(context_, if_true, if_false);
|
| + context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| @@ -2028,80 +1992,80 @@
|
|
|
| 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);
|
|
|
| __ BranchOnSmi(r0, if_false);
|
| __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE);
|
| Split(eq, 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);
|
|
|
| __ BranchOnSmi(r0, if_false);
|
| __ CompareObjectType(r0, r1, r1, JS_ARRAY_TYPE);
|
| Split(eq, 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);
|
|
|
| __ BranchOnSmi(r0, if_false);
|
| __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE);
|
| Split(eq, if_true, if_false, fall_through);
|
|
|
| - Apply(context_, if_true, if_false);
|
| + context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| @@ -2113,8 +2077,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.
|
| __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
|
| @@ -2132,7 +2096,7 @@
|
| __ cmp(r1, Operand(Smi::FromInt(StackFrame::CONSTRUCT)));
|
| Split(eq, if_true, if_false, fall_through);
|
|
|
| - Apply(context_, if_true, if_false);
|
| + context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| @@ -2140,21 +2104,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(r1);
|
| __ cmp(r0, r1);
|
| Split(eq, if_true, if_false, fall_through);
|
|
|
| - Apply(context_, if_true, if_false);
|
| + context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| @@ -2162,13 +2126,13 @@
|
| ASSERT(args->length() == 1);
|
|
|
| // ArgumentsAccessStub expects the key in edx and the formal
|
| - // parameter count in eax.
|
| - VisitForValue(args->at(0), kAccumulator);
|
| + // parameter count in r0.
|
| + VisitForAccumulatorValue(args->at(0));
|
| __ mov(r1, r0);
|
| __ mov(r0, Operand(Smi::FromInt(scope()->num_parameters())));
|
| ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT);
|
| __ CallStub(&stub);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2190,7 +2154,7 @@
|
| __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset));
|
|
|
| __ bind(&exit);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2198,7 +2162,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.
|
| __ BranchOnSmi(r0, &null);
|
| @@ -2244,7 +2208,7 @@
|
| // All done.
|
| __ bind(&done);
|
|
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2259,14 +2223,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(r0, Heap::kUndefinedValueRootIndex);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2316,7 +2280,7 @@
|
| ExternalReference::fill_heap_number_with_random_function(), 1);
|
| }
|
|
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2324,11 +2288,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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2336,19 +2300,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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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.
|
| @@ -2359,25 +2323,25 @@
|
| __ ldr(r0, FieldMemOperand(r0, JSValue::kValueOffset));
|
|
|
| __ bind(&done);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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(r1); // r0 = value. r1 = object.
|
|
|
| Label done;
|
| @@ -2395,7 +2359,7 @@
|
| __ RecordWrite(r1, Operand(JSValue::kValueOffset - kHeapObjectTag), r2, r3);
|
|
|
| __ bind(&done);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2403,18 +2367,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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| void FullCodeGenerator::EmitStringCharFromCode(ZoneList<Expression*>* args) {
|
| ASSERT(args->length() == 1);
|
|
|
| - VisitForValue(args->at(0), kAccumulator);
|
| + VisitForAccumulatorValue(args->at(0));
|
|
|
| Label done;
|
| StringCharFromCodeGenerator generator(r0, r1);
|
| @@ -2425,15 +2389,15 @@
|
| generator.GenerateSlow(masm_, call_helper);
|
|
|
| __ bind(&done);
|
| - Apply(context_, r1);
|
| + context()->Plug(r1);
|
| }
|
|
|
|
|
| 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 = r1;
|
| Register index = r0;
|
| @@ -2472,15 +2436,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 = r1;
|
| Register index = r0;
|
| @@ -2521,58 +2485,58 @@
|
| 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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| void FullCodeGenerator::EmitMathSin(ZoneList<Expression*>* args) {
|
| // Load the argument on the stack and call the runtime.
|
| ASSERT(args->length() == 1);
|
| - VisitForValue(args->at(0), kStack);
|
| + VisitForStackValue(args->at(0));
|
| __ CallRuntime(Runtime::kMath_sin, 1);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| void FullCodeGenerator::EmitMathCos(ZoneList<Expression*>* args) {
|
| // Load the argument on the stack and call the runtime.
|
| ASSERT(args->length() == 1);
|
| - VisitForValue(args->at(0), kStack);
|
| + VisitForStackValue(args->at(0));
|
| __ CallRuntime(Runtime::kMath_cos, 1);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2580,38 +2544,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 r1. Move it in there.
|
| if (!result_register().is(r1)) __ mov(r1, result_register());
|
| ParameterCount count(arg_count);
|
| __ InvokeFunction(r1, count, CALL_FUNCTION);
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| 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_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2626,11 +2590,11 @@
|
| if (jsfunction_result_caches->length() <= cache_id) {
|
| __ Abort("Attempt to use undefined cache.");
|
| __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| return;
|
| }
|
|
|
| - VisitForValue(args->at(1), kAccumulator);
|
| + VisitForAccumulatorValue(args->at(1));
|
|
|
| Register key = r0;
|
| Register cache = r1;
|
| @@ -2662,7 +2626,7 @@
|
| __ CallRuntime(Runtime::kGetFromCache, 2);
|
|
|
| __ bind(&done);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2674,8 +2638,8 @@
|
| Register tmp = r2;
|
| Register tmp2 = r3;
|
|
|
| - VisitForValue(args->at(0), kStack);
|
| - VisitForValue(args->at(1), kAccumulator);
|
| + VisitForStackValue(args->at(0));
|
| + VisitForAccumulatorValue(args->at(1));
|
| __ pop(left);
|
|
|
| Label done, fail, ok;
|
| @@ -2703,19 +2667,19 @@
|
| __ LoadRoot(r0, Heap::kTrueValueRootIndex);
|
| __ bind(&done);
|
|
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList<Expression*>* args) {
|
| - 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);
|
|
|
| __ ldr(r0, FieldMemOperand(r0, String::kHashFieldOffset));
|
| __ tst(r0, Operand(String::kContainsCachedArrayIndexMask));
|
| @@ -2723,16 +2687,16 @@
|
| __ b(eq, if_true);
|
| __ b(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));
|
| __ ldr(r0, FieldMemOperand(r0, String::kHashFieldOffset));
|
| __ IndexFromHash(r0, r0);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2757,7 +2721,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()) {
|
| @@ -2772,7 +2736,7 @@
|
| // Call the C runtime function.
|
| __ CallRuntime(expr->function(), arg_count);
|
| }
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
| @@ -2786,20 +2750,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()) {
|
| __ ldr(r1, CodeGenerator::GlobalObject());
|
| __ mov(r0, Operand(var->name()));
|
| @@ -2816,7 +2780,7 @@
|
| __ push(r2);
|
| }
|
| __ InvokeBuiltin(Builtins::DELETE, CALL_JS);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| break;
|
| }
|
| @@ -2824,26 +2788,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:
|
| - __ LoadRoot(result_register(), Heap::kUndefinedValueRootIndex);
|
| - switch (location_) {
|
| - case kAccumulator:
|
| - break;
|
| - case kStack:
|
| - __ push(result_register());
|
| - break;
|
| - }
|
| - break;
|
| - case Expression::kTest:
|
| - __ jmp(false_label_);
|
| - break;
|
| - }
|
| + context()->Plug(Heap::kUndefinedValueRootIndex);
|
| break;
|
| }
|
|
|
| @@ -2855,31 +2800,33 @@
|
| 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_, r0);
|
| + context()->Plug(r0);
|
| break;
|
| }
|
|
|
| case Token::ADD: {
|
| Comment cmt(masm_, "[ UnaryOperation (ADD)");
|
| - VisitForValue(expr->expression(), kAccumulator);
|
| + VisitForAccumulatorValue(expr->expression());
|
| Label no_conversion;
|
| __ tst(result_register(), Operand(kSmiTagMask));
|
| __ b(eq, &no_conversion);
|
| __ push(r0);
|
| __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_JS);
|
| __ bind(&no_conversion);
|
| - Apply(context_, result_register());
|
| + context()->Plug(result_register());
|
| break;
|
| }
|
|
|
| @@ -2891,9 +2838,9 @@
|
| GenericUnaryOpStub stub(Token::SUB, overwrite);
|
| // GenericUnaryOpStub expects the argument to be in the
|
| // accumulator register r0.
|
| - VisitForValue(expr->expression(), kAccumulator);
|
| + VisitForAccumulatorValue(expr->expression());
|
| __ CallStub(&stub);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| break;
|
| }
|
|
|
| @@ -2901,7 +2848,7 @@
|
| Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)");
|
| // The generic unary operation stub expects the argument to be
|
| // in the accumulator register r0.
|
| - VisitForValue(expr->expression(), kAccumulator);
|
| + VisitForAccumulatorValue(expr->expression());
|
| Label done;
|
| if (ShouldInlineSmiCase(expr->op())) {
|
| Label call_stub;
|
| @@ -2918,7 +2865,7 @@
|
| GenericUnaryOpStub stub(Token::BIT_NOT, mode);
|
| __ CallStub(&stub);
|
| __ bind(&done);
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| break;
|
| }
|
|
|
| @@ -2954,25 +2901,22 @@
|
| // 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()) {
|
| __ mov(ip, Operand(Smi::FromInt(0)));
|
| __ push(ip);
|
| }
|
| if (assign_type == NAMED_PROPERTY) {
|
| // Put the object both on the stack and in the accumulator.
|
| - VisitForValue(prop->obj(), kAccumulator);
|
| + VisitForAccumulatorValue(prop->obj());
|
| __ push(r0);
|
| EmitNamedPropertyLoad(prop);
|
| } else {
|
| - VisitForValue(prop->obj(), kStack);
|
| - VisitForValue(prop->key(), kAccumulator);
|
| + VisitForStackValue(prop->obj());
|
| + VisitForAccumulatorValue(prop->key());
|
| __ ldr(r1, MemOperand(sp, 0));
|
| __ push(r0);
|
| EmitKeyedPropertyLoad(prop);
|
| @@ -2988,29 +2932,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(r0);
|
| - break;
|
| - case NAMED_PROPERTY:
|
| - __ str(r0, MemOperand(sp, kPointerSize));
|
| - break;
|
| - case KEYED_PROPERTY:
|
| - __ str(r0, MemOperand(sp, 2 * kPointerSize));
|
| - 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(r0);
|
| + break;
|
| + case NAMED_PROPERTY:
|
| + __ str(r0, MemOperand(sp, kPointerSize));
|
| + break;
|
| + case KEYED_PROPERTY:
|
| + __ str(r0, MemOperand(sp, 2 * kPointerSize));
|
| + break;
|
| + }
|
| }
|
| }
|
|
|
| @@ -3037,18 +2973,19 @@
|
| switch (assign_type) {
|
| case VARIABLE:
|
| if (expr->is_postfix()) {
|
| - EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
|
| - Token::ASSIGN,
|
| - Expression::kEffect);
|
| - // For all contexts except kEffect: We have the result on
|
| + {
|
| + EffectContext context(this);
|
| + EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
|
| + Token::ASSIGN);
|
| + }
|
| + // For all contexts except EffectConstant We have the result on
|
| // top of the stack.
|
| - if (context_ != Expression::kEffect) {
|
| - ApplyTOS(context_);
|
| + if (!context()->IsEffect()) {
|
| + context()->PlugTOS();
|
| }
|
| } else {
|
| EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
|
| - Token::ASSIGN,
|
| - context_);
|
| + Token::ASSIGN);
|
| }
|
| break;
|
| case NAMED_PROPERTY: {
|
| @@ -3057,11 +2994,11 @@
|
| Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
|
| __ Call(ic, RelocInfo::CODE_TARGET);
|
| if (expr->is_postfix()) {
|
| - if (context_ != Expression::kEffect) {
|
| - ApplyTOS(context_);
|
| + if (!context()->IsEffect()) {
|
| + context()->PlugTOS();
|
| }
|
| } else {
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| break;
|
| }
|
| @@ -3071,11 +3008,11 @@
|
| Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize));
|
| __ Call(ic, RelocInfo::CODE_TARGET);
|
| if (expr->is_postfix()) {
|
| - if (context_ != Expression::kEffect) {
|
| - ApplyTOS(context_);
|
| + if (!context()->IsEffect()) {
|
| + context()->PlugTOS();
|
| }
|
| } else {
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
| break;
|
| }
|
| @@ -3083,7 +3020,9 @@
|
| }
|
|
|
|
|
| -void FullCodeGenerator::VisitForTypeofValue(Expression* expr, Location where) {
|
| +void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
|
| + ASSERT(!context()->IsEffect());
|
| + ASSERT(!context()->IsTest());
|
| VariableProxy* proxy = expr->AsVariableProxy();
|
| if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) {
|
| Comment cmnt(masm_, "Global variable");
|
| @@ -3093,7 +3032,7 @@
|
| // Use a regular load, not a contextual load, to avoid a reference
|
| // error.
|
| __ Call(ic, RelocInfo::CODE_TARGET);
|
| - if (where == kStack) __ push(r0);
|
| + context()->Plug(r0);
|
| } else if (proxy != NULL &&
|
| proxy->var()->slot() != NULL &&
|
| proxy->var()->slot()->type() == Slot::LOOKUP) {
|
| @@ -3110,10 +3049,10 @@
|
| __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2);
|
| __ bind(&done);
|
|
|
| - if (where == kStack) __ push(r0);
|
| + context()->Plug(r0);
|
| } else {
|
| // This expression cannot throw a reference error at the top level.
|
| - VisitForValue(expr, where);
|
| + Visit(expr);
|
| }
|
| }
|
|
|
| @@ -3135,7 +3074,9 @@
|
| 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())) {
|
| __ tst(r0, Operand(kSmiTagMask));
|
| __ b(eq, if_true);
|
| @@ -3221,8 +3162,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.
|
| @@ -3230,14 +3171,14 @@
|
| 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_JS);
|
| __ LoadRoot(ip, Heap::kTrueValueRootIndex);
|
| __ cmp(r0, ip);
|
| @@ -3245,7 +3186,7 @@
|
| break;
|
|
|
| case Token::INSTANCEOF: {
|
| - VisitForValue(expr->right(), kStack);
|
| + VisitForStackValue(expr->right());
|
| InstanceofStub stub;
|
| __ CallStub(&stub);
|
| // The stub returns 0 for true.
|
| @@ -3255,7 +3196,7 @@
|
| }
|
|
|
| default: {
|
| - VisitForValue(expr->right(), kAccumulator);
|
| + VisitForAccumulatorValue(expr->right());
|
| Condition cc = eq;
|
| bool strict = false;
|
| switch (op) {
|
| @@ -3310,7 +3251,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);
|
| }
|
|
|
|
|
| @@ -3320,10 +3261,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());
|
| __ LoadRoot(r1, Heap::kNullValueRootIndex);
|
| __ cmp(r0, r1);
|
| if (expr->is_strict()) {
|
| @@ -3342,13 +3283,13 @@
|
| __ cmp(r1, Operand(1 << Map::kIsUndetectable));
|
| Split(eq, if_true, if_false, fall_through);
|
| }
|
| - Apply(context_, if_true, if_false);
|
| + context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) {
|
| __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
|
| - Apply(context_, r0);
|
| + context()->Plug(r0);
|
| }
|
|
|
|
|
|
|