OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 OperandStackDepthDecrement(arg_count + 1); | 2446 OperandStackDepthDecrement(arg_count + 1); |
2447 | 2447 |
2448 RecordJSReturnSite(expr); | 2448 RecordJSReturnSite(expr); |
2449 | 2449 |
2450 // Restore context register. | 2450 // Restore context register. |
2451 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2451 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2452 | 2452 |
2453 context()->DropAndPlug(1, eax); | 2453 context()->DropAndPlug(1, eax); |
2454 } | 2454 } |
2455 | 2455 |
2456 | 2456 void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) { |
2457 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2457 int arg_count = expr->arguments()->length(); |
2458 // Push copy of the first argument or undefined if it doesn't exist. | 2458 // Push copy of the first argument or undefined if it doesn't exist. |
2459 if (arg_count > 0) { | 2459 if (arg_count > 0) { |
2460 __ push(Operand(esp, arg_count * kPointerSize)); | 2460 __ push(Operand(esp, arg_count * kPointerSize)); |
2461 } else { | 2461 } else { |
2462 __ push(Immediate(isolate()->factory()->undefined_value())); | 2462 __ push(Immediate(isolate()->factory()->undefined_value())); |
2463 } | 2463 } |
2464 | 2464 |
2465 // Push the enclosing function. | 2465 // Push the enclosing function. |
2466 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 2466 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
2467 | 2467 |
2468 // Push the language mode. | 2468 // Push the language mode. |
2469 __ push(Immediate(Smi::FromInt(language_mode()))); | 2469 __ push(Immediate(Smi::FromInt(language_mode()))); |
2470 | 2470 |
2471 // Push the start position of the scope the calls resides in. | 2471 // Push the start position of the scope the calls resides in. |
2472 __ push(Immediate(Smi::FromInt(scope()->start_position()))); | 2472 __ push(Immediate(Smi::FromInt(scope()->start_position()))); |
2473 | 2473 |
| 2474 // Push the source position of the eval call. |
| 2475 __ push(Immediate(Smi::FromInt(expr->position()))); |
| 2476 |
2474 // Do the runtime call. | 2477 // Do the runtime call. |
2475 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); | 2478 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); |
2476 } | 2479 } |
2477 | 2480 |
2478 | 2481 |
2479 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | 2482 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. |
2480 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { | 2483 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
2481 VariableProxy* callee = expr->expression()->AsVariableProxy(); | 2484 VariableProxy* callee = expr->expression()->AsVariableProxy(); |
2482 if (callee->var()->IsLookupSlot()) { | 2485 if (callee->var()->IsLookupSlot()) { |
2483 Label slow, done; | 2486 Label slow, done; |
(...skipping 26 matching lines...) Expand all Loading... |
2510 } | 2513 } |
2511 } else { | 2514 } else { |
2512 VisitForStackValue(callee); | 2515 VisitForStackValue(callee); |
2513 // refEnv.WithBaseObject() | 2516 // refEnv.WithBaseObject() |
2514 PushOperand(isolate()->factory()->undefined_value()); | 2517 PushOperand(isolate()->factory()->undefined_value()); |
2515 } | 2518 } |
2516 } | 2519 } |
2517 | 2520 |
2518 | 2521 |
2519 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { | 2522 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
2520 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 2523 // In a call to eval, we first call Runtime_ResolvePossiblyDirectEval |
2521 // to resolve the function we need to call. Then we call the resolved | 2524 // to resolve the function we need to call. Then we call the resolved |
2522 // function using the given arguments. | 2525 // function using the given arguments. |
2523 ZoneList<Expression*>* args = expr->arguments(); | 2526 ZoneList<Expression*>* args = expr->arguments(); |
2524 int arg_count = args->length(); | 2527 int arg_count = args->length(); |
2525 | 2528 |
2526 PushCalleeAndWithBaseObject(expr); | 2529 PushCalleeAndWithBaseObject(expr); |
2527 | 2530 |
2528 // Push the arguments. | 2531 // Push the arguments. |
2529 for (int i = 0; i < arg_count; i++) { | 2532 for (int i = 0; i < arg_count; i++) { |
2530 VisitForStackValue(args->at(i)); | 2533 VisitForStackValue(args->at(i)); |
2531 } | 2534 } |
2532 | 2535 |
2533 // Push a copy of the function (found below the arguments) and | 2536 // Push a copy of the function (found below the arguments) and |
2534 // resolve eval. | 2537 // resolve eval. |
2535 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); | 2538 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); |
2536 EmitResolvePossiblyDirectEval(arg_count); | 2539 EmitResolvePossiblyDirectEval(expr); |
2537 | 2540 |
2538 // Touch up the stack with the resolved function. | 2541 // Touch up the stack with the resolved function. |
2539 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 2542 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
2540 | 2543 |
2541 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2544 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
2542 | 2545 |
2543 SetCallPosition(expr); | 2546 SetCallPosition(expr); |
2544 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2547 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2545 __ Set(eax, arg_count); | 2548 __ Set(eax, arg_count); |
2546 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2549 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 isolate->builtins()->OnStackReplacement()->entry(), | 3891 isolate->builtins()->OnStackReplacement()->entry(), |
3889 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3892 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3890 return ON_STACK_REPLACEMENT; | 3893 return ON_STACK_REPLACEMENT; |
3891 } | 3894 } |
3892 | 3895 |
3893 | 3896 |
3894 } // namespace internal | 3897 } // namespace internal |
3895 } // namespace v8 | 3898 } // namespace v8 |
3896 | 3899 |
3897 #endif // V8_TARGET_ARCH_X87 | 3900 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |