| Index: src/x64/full-codegen-x64.cc
|
| diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
|
| index 831a7df0ef1c3af2a675b527e302cd9e00d2ebc0..e8fdef21f95f396beaec1e556cf4518c047da4aa 100644
|
| --- a/src/x64/full-codegen-x64.cc
|
| +++ b/src/x64/full-codegen-x64.cc
|
| @@ -378,7 +378,7 @@ void FullCodeGenerator::StackValueContext::Plug(Variable* var) const {
|
|
|
| void FullCodeGenerator::TestContext::Plug(Variable* var) const {
|
| codegen()->GetVar(result_register(), var);
|
| - codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
|
| + codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL);
|
| codegen()->DoTest(this);
|
| }
|
|
|
| @@ -400,7 +400,7 @@ void FullCodeGenerator::StackValueContext::Plug(
|
|
|
|
|
| void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const {
|
| - codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
|
| + codegen()->PrepareForBailoutBeforeSplit(condition(),
|
| true,
|
| true_label_,
|
| false_label_);
|
| @@ -433,7 +433,7 @@ void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
|
|
|
|
|
| void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
| - codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
|
| + codegen()->PrepareForBailoutBeforeSplit(condition(),
|
| true,
|
| true_label_,
|
| false_label_);
|
| @@ -492,7 +492,7 @@ void FullCodeGenerator::TestContext::DropAndPlug(int count,
|
| // For simplicity we always test the accumulator register.
|
| __ Drop(count);
|
| __ Move(result_register(), reg);
|
| - codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
|
| + codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL);
|
| codegen()->DoTest(this);
|
| }
|
|
|
| @@ -556,7 +556,7 @@ void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
|
|
|
|
|
| void FullCodeGenerator::TestContext::Plug(bool flag) const {
|
| - codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
|
| + codegen()->PrepareForBailoutBeforeSplit(condition(),
|
| true,
|
| true_label_,
|
| false_label_);
|
| @@ -648,7 +648,7 @@ void FullCodeGenerator::SetVar(Variable* var,
|
| }
|
|
|
|
|
| -void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state,
|
| +void FullCodeGenerator::PrepareForBailoutBeforeSplit(Expression* expr,
|
| bool should_normalize,
|
| Label* if_true,
|
| Label* if_false) {
|
| @@ -659,13 +659,7 @@ void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state,
|
|
|
| Label skip;
|
| if (should_normalize) __ jmp(&skip, Label::kNear);
|
| -
|
| - ForwardBailoutStack* current = forward_bailout_stack_;
|
| - while (current != NULL) {
|
| - PrepareForBailout(current->expr(), state);
|
| - current = current->parent();
|
| - }
|
| -
|
| + PrepareForBailout(expr, TOS_REG);
|
| if (should_normalize) {
|
| __ CompareRoot(rax, Heap::kTrueValueRootIndex);
|
| Split(equal, if_true, if_false, NULL);
|
| @@ -2264,7 +2258,8 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2276,7 +2271,7 @@ void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) {
|
| context()->PrepareTest(&materialize_true, &materialize_false,
|
| &if_true, &if_false, &fall_through);
|
|
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| __ JumpIfSmi(rax, if_true);
|
| __ jmp(if_false);
|
|
|
| @@ -2284,7 +2279,8 @@ void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsNonNegativeSmi(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2296,7 +2292,7 @@ void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) {
|
| context()->PrepareTest(&materialize_true, &materialize_false,
|
| &if_true, &if_false, &fall_through);
|
|
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Condition non_negative_smi = masm()->CheckNonNegativeSmi(rax);
|
| Split(non_negative_smi, if_true, if_false, fall_through);
|
|
|
| @@ -2304,7 +2300,8 @@ void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsObject(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsObject(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2328,14 +2325,15 @@ void FullCodeGenerator::EmitIsObject(ZoneList<Expression*>* args) {
|
| __ cmpq(rbx, Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE));
|
| __ j(below, if_false);
|
| __ cmpq(rbx, Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE));
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(below_equal, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsSpecObject(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2349,14 +2347,15 @@ void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) {
|
|
|
| __ JumpIfSmi(rax, if_false);
|
| __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rbx);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(above_equal, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsUndetectableObject(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2372,7 +2371,7 @@ void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) {
|
| __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
|
| __ testb(FieldOperand(rbx, Map::kBitFieldOffset),
|
| Immediate(1 << Map::kIsUndetectable));
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(not_zero, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| @@ -2380,7 +2379,8 @@ void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) {
|
|
|
|
|
| void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf(
|
| - ZoneList<Expression*>* args) {
|
| + CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2456,12 +2456,13 @@ void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf(
|
| Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
|
| __ jmp(if_true);
|
|
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2475,14 +2476,15 @@ void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) {
|
|
|
| __ JumpIfSmi(rax, if_false);
|
| __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(equal, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsArray(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsArray(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2496,14 +2498,15 @@ void FullCodeGenerator::EmitIsArray(ZoneList<Expression*>* args) {
|
|
|
| __ JumpIfSmi(rax, if_false);
|
| __ CmpObjectType(rax, JS_ARRAY_TYPE, rbx);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(equal, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsRegExp(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsRegExp(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2517,7 +2520,7 @@ void FullCodeGenerator::EmitIsRegExp(ZoneList<Expression*>* args) {
|
|
|
| __ JumpIfSmi(rax, if_false);
|
| __ CmpObjectType(rax, JS_REGEXP_TYPE, rbx);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(equal, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| @@ -2525,8 +2528,8 @@ void FullCodeGenerator::EmitIsRegExp(ZoneList<Expression*>* args) {
|
|
|
|
|
|
|
| -void FullCodeGenerator::EmitIsConstructCall(ZoneList<Expression*>* args) {
|
| - ASSERT(args->length() == 0);
|
| +void FullCodeGenerator::EmitIsConstructCall(CallRuntime* expr) {
|
| + ASSERT(expr->arguments()->length() == 0);
|
|
|
| Label materialize_true, materialize_false;
|
| Label* if_true = NULL;
|
| @@ -2549,14 +2552,15 @@ void FullCodeGenerator::EmitIsConstructCall(ZoneList<Expression*>* args) {
|
| __ bind(&check_frame_marker);
|
| __ Cmp(Operand(rax, StandardFrameConstants::kMarkerOffset),
|
| Smi::FromInt(StackFrame::CONSTRUCT));
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(equal, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitObjectEquals(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitObjectEquals(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 2);
|
|
|
| // Load the two objects into registers and perform the comparison.
|
| @@ -2572,14 +2576,15 @@ void FullCodeGenerator::EmitObjectEquals(ZoneList<Expression*>* args) {
|
|
|
| __ pop(rbx);
|
| __ cmpq(rax, rbx);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Split(equal, if_true, if_false, fall_through);
|
|
|
| context()->Plug(if_true, if_false);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitArguments(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitArguments(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| // ArgumentsAccessStub expects the key in rdx and the formal
|
| @@ -2593,8 +2598,8 @@ void FullCodeGenerator::EmitArguments(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitArgumentsLength(ZoneList<Expression*>* args) {
|
| - ASSERT(args->length() == 0);
|
| +void FullCodeGenerator::EmitArgumentsLength(CallRuntime* expr) {
|
| + ASSERT(expr->arguments()->length() == 0);
|
|
|
| Label exit;
|
| // Get the number of formal parameters.
|
| @@ -2616,7 +2621,8 @@ void FullCodeGenerator::EmitArgumentsLength(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitClassOf(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitClassOf(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
| Label done, null, function, non_function_constructor;
|
|
|
| @@ -2676,7 +2682,7 @@ void FullCodeGenerator::EmitClassOf(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitLog(CallRuntime* expr) {
|
| // Conditionally generate a log call.
|
| // Args:
|
| // 0 (literal string): The type of logging (corresponds to the flags).
|
| @@ -2684,6 +2690,7 @@ void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) {
|
| // 1 (string): Format string. Access the string at argument index 2
|
| // with '%2s' (see Logger::LogRuntime for all the formats).
|
| // 2 (array): Arguments to the format string.
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(args->length(), 3);
|
| if (CodeGenerator::ShouldGenerateLog(args->at(0))) {
|
| VisitForStackValue(args->at(1));
|
| @@ -2696,8 +2703,8 @@ void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) {
|
| - ASSERT(args->length() == 0);
|
| +void FullCodeGenerator::EmitRandomHeapNumber(CallRuntime* expr) {
|
| + ASSERT(expr->arguments()->length() == 0);
|
|
|
| Label slow_allocate_heapnumber;
|
| Label heapnumber_allocated;
|
| @@ -2741,9 +2748,10 @@ void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitSubString(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitSubString(CallRuntime* expr) {
|
| // Load the arguments on the stack and call the stub.
|
| SubStringStub stub;
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 3);
|
| VisitForStackValue(args->at(0));
|
| VisitForStackValue(args->at(1));
|
| @@ -2753,9 +2761,10 @@ void FullCodeGenerator::EmitSubString(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitRegExpExec(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) {
|
| // Load the arguments on the stack and call the stub.
|
| RegExpExecStub stub;
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 4);
|
| VisitForStackValue(args->at(0));
|
| VisitForStackValue(args->at(1));
|
| @@ -2766,7 +2775,8 @@ void FullCodeGenerator::EmitRegExpExec(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitValueOf(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitValueOf(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0)); // Load the object.
|
| @@ -2784,8 +2794,9 @@ void FullCodeGenerator::EmitValueOf(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitMathPow(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
|
| // Load the arguments on the stack and call the runtime function.
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 2);
|
| VisitForStackValue(args->at(0));
|
| VisitForStackValue(args->at(1));
|
| @@ -2795,7 +2806,8 @@ void FullCodeGenerator::EmitMathPow(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitSetValueOf(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 2);
|
|
|
| VisitForStackValue(args->at(0)); // Load the object.
|
| @@ -2822,7 +2834,8 @@ void FullCodeGenerator::EmitSetValueOf(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(args->length(), 1);
|
|
|
| // Load the argument on the stack and call the stub.
|
| @@ -2834,7 +2847,8 @@ void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitStringCharFromCode(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -2852,7 +2866,8 @@ void FullCodeGenerator::EmitStringCharFromCode(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitStringCharCodeAt(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitStringCharCodeAt(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 2);
|
|
|
| VisitForStackValue(args->at(0));
|
| @@ -2899,7 +2914,8 @@ void FullCodeGenerator::EmitStringCharCodeAt(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitStringCharAt(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 2);
|
|
|
| VisitForStackValue(args->at(0));
|
| @@ -2948,7 +2964,8 @@ void FullCodeGenerator::EmitStringCharAt(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitStringAdd(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(2, args->length());
|
|
|
| VisitForStackValue(args->at(0));
|
| @@ -2960,7 +2977,8 @@ void FullCodeGenerator::EmitStringAdd(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitStringCompare(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(2, args->length());
|
|
|
| VisitForStackValue(args->at(0));
|
| @@ -2972,10 +2990,11 @@ void FullCodeGenerator::EmitStringCompare(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitMathSin(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitMathSin(CallRuntime* expr) {
|
| // Load the argument on the stack and call the stub.
|
| TranscendentalCacheStub stub(TranscendentalCache::SIN,
|
| TranscendentalCacheStub::TAGGED);
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
| VisitForStackValue(args->at(0));
|
| __ CallStub(&stub);
|
| @@ -2983,10 +3002,11 @@ void FullCodeGenerator::EmitMathSin(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitMathCos(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitMathCos(CallRuntime* expr) {
|
| // Load the argument on the stack and call the stub.
|
| TranscendentalCacheStub stub(TranscendentalCache::COS,
|
| TranscendentalCacheStub::TAGGED);
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
| VisitForStackValue(args->at(0));
|
| __ CallStub(&stub);
|
| @@ -2994,10 +3014,11 @@ void FullCodeGenerator::EmitMathCos(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitMathLog(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitMathLog(CallRuntime* expr) {
|
| // Load the argument on the stack and call the stub.
|
| TranscendentalCacheStub stub(TranscendentalCache::LOG,
|
| TranscendentalCacheStub::TAGGED);
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
| VisitForStackValue(args->at(0));
|
| __ CallStub(&stub);
|
| @@ -3005,8 +3026,9 @@ void FullCodeGenerator::EmitMathLog(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitMathSqrt(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) {
|
| // Load the argument on the stack and call the runtime function.
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
| VisitForStackValue(args->at(0));
|
| __ CallRuntime(Runtime::kMath_sqrt, 1);
|
| @@ -3014,7 +3036,8 @@ void FullCodeGenerator::EmitMathSqrt(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitCallFunction(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() >= 2);
|
|
|
| int arg_count = args->length() - 2; // 2 ~ receiver and function.
|
| @@ -3033,8 +3056,9 @@ void FullCodeGenerator::EmitCallFunction(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitRegExpConstructResult(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) {
|
| RegExpConstructResultStub stub;
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 3);
|
| VisitForStackValue(args->at(0));
|
| VisitForStackValue(args->at(1));
|
| @@ -3044,7 +3068,8 @@ void FullCodeGenerator::EmitRegExpConstructResult(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitSwapElements(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 3);
|
| VisitForStackValue(args->at(0));
|
| VisitForStackValue(args->at(1));
|
| @@ -3139,7 +3164,8 @@ void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(2, args->length());
|
|
|
| ASSERT_NE(NULL, args->at(0)->AsLiteral());
|
| @@ -3195,7 +3221,8 @@ void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitIsRegExpEquivalent(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitIsRegExpEquivalent(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT_EQ(2, args->length());
|
|
|
| Register right = rax;
|
| @@ -3233,7 +3260,8 @@ void FullCodeGenerator::EmitIsRegExpEquivalent(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
|
|
| VisitForAccumulatorValue(args->at(0));
|
| @@ -3247,7 +3275,7 @@ void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList<Expression*>* args) {
|
|
|
| __ testl(FieldOperand(rax, String::kHashFieldOffset),
|
| Immediate(String::kContainsCachedArrayIndexMask));
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| __ j(zero, if_true);
|
| __ jmp(if_false);
|
|
|
| @@ -3255,7 +3283,8 @@ void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) {
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 1);
|
| VisitForAccumulatorValue(args->at(0));
|
|
|
| @@ -3271,10 +3300,11 @@ void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList<Expression*>* args) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList<Expression*>* args) {
|
| +void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) {
|
| Label bailout, return_result, done, one_char_separator, long_separator,
|
| non_trivial_array, not_size_one_array, loop,
|
| loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
|
| + ZoneList<Expression*>* args = expr->arguments();
|
| ASSERT(args->length() == 2);
|
| // We will leave the separator on the stack until the end of the function.
|
| VisitForStackValue(args->at(1));
|
| @@ -3653,17 +3683,41 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
|
| // Unary NOT has no side effects so it's only necessary to visit the
|
| // subexpression. Match the optimizing compiler by not branching.
|
| VisitForEffect(expr->expression());
|
| + } else if (context()->IsTest()) {
|
| + const TestContext* test = TestContext::cast(context());
|
| + // The labels are swapped for the recursive call.
|
| + VisitForControl(expr->expression(),
|
| + test->false_label(),
|
| + test->true_label(),
|
| + test->fall_through());
|
| + context()->Plug(test->true_label(), test->false_label());
|
| } else {
|
| - Label materialize_true, materialize_false;
|
| - Label* if_true = NULL;
|
| - Label* if_false = NULL;
|
| - Label* fall_through = NULL;
|
| - // Notice that the labels are swapped.
|
| - context()->PrepareTest(&materialize_true, &materialize_false,
|
| - &if_false, &if_true, &fall_through);
|
| - if (context()->IsTest()) ForwardBailoutToChild(expr);
|
| - VisitForControl(expr->expression(), if_true, if_false, fall_through);
|
| - context()->Plug(if_false, if_true); // Labels swapped.
|
| + // We handle value contexts explicitly rather than simply visiting
|
| + // for control and plugging the control flow into the context,
|
| + // because we need to prepare a pair of extra administrative AST ids
|
| + // for the optimizing compiler.
|
| + ASSERT(context()->IsAccumulatorValue() || context()->IsStackValue());
|
| + Label materialize_true, materialize_false, done;
|
| + VisitForControl(expr->expression(),
|
| + &materialize_false,
|
| + &materialize_true,
|
| + &materialize_true);
|
| + __ bind(&materialize_true);
|
| + PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS);
|
| + if (context()->IsAccumulatorValue()) {
|
| + __ LoadRoot(rax, Heap::kTrueValueRootIndex);
|
| + } else {
|
| + __ PushRoot(Heap::kTrueValueRootIndex);
|
| + }
|
| + __ jmp(&done, Label::kNear);
|
| + __ bind(&materialize_false);
|
| + PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS);
|
| + if (context()->IsAccumulatorValue()) {
|
| + __ LoadRoot(rax, Heap::kFalseValueRootIndex);
|
| + } else {
|
| + __ PushRoot(Heap::kFalseValueRootIndex);
|
| + }
|
| + __ bind(&done);
|
| }
|
| break;
|
| }
|
| @@ -3935,12 +3989,13 @@ void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
|
| context()->Plug(rax);
|
| } else {
|
| // This expression cannot throw a reference error at the top level.
|
| - VisitInCurrentContext(expr);
|
| + VisitInDuplicateContext(expr);
|
| }
|
| }
|
|
|
|
|
| void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
|
| + Expression* sub_expr,
|
| Handle<String> check) {
|
| Label materialize_true, materialize_false;
|
| Label* if_true = NULL;
|
| @@ -3950,9 +4005,9 @@ void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
|
| &if_true, &if_false, &fall_through);
|
|
|
| { AccumulatorValueContext context(this);
|
| - VisitForTypeofValue(expr);
|
| + VisitForTypeofValue(sub_expr);
|
| }
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
|
|
| if (check->Equals(isolate()->heap()->number_symbol())) {
|
| __ JumpIfSmi(rax, if_true);
|
| @@ -4036,7 +4091,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
|
| case Token::IN:
|
| VisitForStackValue(expr->right());
|
| __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
|
| + PrepareForBailoutBeforeSplit(expr, false, NULL, NULL);
|
| __ CompareRoot(rax, Heap::kTrueValueRootIndex);
|
| Split(equal, if_true, if_false, fall_through);
|
| break;
|
| @@ -4045,7 +4100,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
|
| VisitForStackValue(expr->right());
|
| InstanceofStub stub(InstanceofStub::kNoFlags);
|
| __ CallStub(&stub);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| __ testq(rax, rax);
|
| // The stub returns 0 for true.
|
| Split(zero, if_true, if_false, fall_through);
|
| @@ -4097,7 +4152,7 @@ void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
|
| __ call(ic, RelocInfo::CODE_TARGET, expr->id());
|
| patch_site.EmitPatchInfo();
|
|
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| __ testq(rax, rax);
|
| Split(cc, if_true, if_false, fall_through);
|
| }
|
| @@ -4120,7 +4175,7 @@ void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr,
|
| &if_true, &if_false, &fall_through);
|
|
|
| VisitForAccumulatorValue(sub_expr);
|
| - PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
|
| + PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
|
| Heap::RootListIndex nil_value = nil == kNullValue ?
|
| Heap::kNullValueRootIndex :
|
| Heap::kUndefinedValueRootIndex;
|
|
|