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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2453 OperandStackDepthDecrement(arg_count + 1); | 2453 OperandStackDepthDecrement(arg_count + 1); |
2454 | 2454 |
2455 RecordJSReturnSite(expr); | 2455 RecordJSReturnSite(expr); |
2456 | 2456 |
2457 // Restore context register. | 2457 // Restore context register. |
2458 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2458 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2459 | 2459 |
2460 context()->DropAndPlug(1, eax); | 2460 context()->DropAndPlug(1, eax); |
2461 } | 2461 } |
2462 | 2462 |
2463 void FullCodeGenerator::EmitResolvePossiblyDirectEval(Call* expr) { | 2463 |
2464 int arg_count = expr->arguments()->length(); | 2464 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2465 // Push copy of the first argument or undefined if it doesn't exist. | 2465 // Push copy of the first argument or undefined if it doesn't exist. |
2466 if (arg_count > 0) { | 2466 if (arg_count > 0) { |
2467 __ push(Operand(esp, arg_count * kPointerSize)); | 2467 __ push(Operand(esp, arg_count * kPointerSize)); |
2468 } else { | 2468 } else { |
2469 __ push(Immediate(isolate()->factory()->undefined_value())); | 2469 __ push(Immediate(isolate()->factory()->undefined_value())); |
2470 } | 2470 } |
2471 | 2471 |
2472 // Push the enclosing function. | 2472 // Push the enclosing function. |
2473 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 2473 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
2474 | 2474 |
2475 // Push the language mode. | 2475 // Push the language mode. |
2476 __ push(Immediate(Smi::FromInt(language_mode()))); | 2476 __ push(Immediate(Smi::FromInt(language_mode()))); |
2477 | 2477 |
2478 // Push the source position of the eval call. | 2478 // Push the start position of the scope the calls resides in. |
2479 __ push(Immediate(Smi::FromInt(expr->position()))); | 2479 __ push(Immediate(Smi::FromInt(scope()->start_position()))); |
2480 | 2480 |
2481 // Do the runtime call. | 2481 // Do the runtime call. |
2482 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); | 2482 __ CallRuntime(Runtime::kResolvePossiblyDirectEval); |
2483 } | 2483 } |
2484 | 2484 |
2485 | 2485 |
2486 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | 2486 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. |
2487 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { | 2487 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
2488 VariableProxy* callee = expr->expression()->AsVariableProxy(); | 2488 VariableProxy* callee = expr->expression()->AsVariableProxy(); |
2489 if (callee->var()->IsLookupSlot()) { | 2489 if (callee->var()->IsLookupSlot()) { |
(...skipping 27 matching lines...) Expand all Loading... |
2517 } | 2517 } |
2518 } else { | 2518 } else { |
2519 VisitForStackValue(callee); | 2519 VisitForStackValue(callee); |
2520 // refEnv.WithBaseObject() | 2520 // refEnv.WithBaseObject() |
2521 PushOperand(isolate()->factory()->undefined_value()); | 2521 PushOperand(isolate()->factory()->undefined_value()); |
2522 } | 2522 } |
2523 } | 2523 } |
2524 | 2524 |
2525 | 2525 |
2526 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { | 2526 void FullCodeGenerator::EmitPossiblyEvalCall(Call* expr) { |
2527 // In a call to eval, we first call Runtime_ResolvePossiblyDirectEval | 2527 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
2528 // to resolve the function we need to call. Then we call the resolved | 2528 // to resolve the function we need to call. Then we call the resolved |
2529 // function using the given arguments. | 2529 // function using the given arguments. |
2530 ZoneList<Expression*>* args = expr->arguments(); | 2530 ZoneList<Expression*>* args = expr->arguments(); |
2531 int arg_count = args->length(); | 2531 int arg_count = args->length(); |
2532 | 2532 |
2533 PushCalleeAndWithBaseObject(expr); | 2533 PushCalleeAndWithBaseObject(expr); |
2534 | 2534 |
2535 // Push the arguments. | 2535 // Push the arguments. |
2536 for (int i = 0; i < arg_count; i++) { | 2536 for (int i = 0; i < arg_count; i++) { |
2537 VisitForStackValue(args->at(i)); | 2537 VisitForStackValue(args->at(i)); |
2538 } | 2538 } |
2539 | 2539 |
2540 // Push a copy of the function (found below the arguments) and | 2540 // Push a copy of the function (found below the arguments) and |
2541 // resolve eval. | 2541 // resolve eval. |
2542 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); | 2542 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); |
2543 EmitResolvePossiblyDirectEval(expr); | 2543 EmitResolvePossiblyDirectEval(arg_count); |
2544 | 2544 |
2545 // Touch up the stack with the resolved function. | 2545 // Touch up the stack with the resolved function. |
2546 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 2546 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
2547 | 2547 |
2548 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); | 2548 PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
2549 | 2549 |
2550 SetCallPosition(expr); | 2550 SetCallPosition(expr); |
2551 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 2551 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
2552 __ Set(eax, arg_count); | 2552 __ Set(eax, arg_count); |
2553 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 2553 __ Call(isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3895 isolate->builtins()->OnStackReplacement()->entry(), | 3895 isolate->builtins()->OnStackReplacement()->entry(), |
3896 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3896 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3897 return ON_STACK_REPLACEMENT; | 3897 return ON_STACK_REPLACEMENT; |
3898 } | 3898 } |
3899 | 3899 |
3900 | 3900 |
3901 } // namespace internal | 3901 } // namespace internal |
3902 } // namespace v8 | 3902 } // namespace v8 |
3903 | 3903 |
3904 #endif // V8_TARGET_ARCH_IA32 | 3904 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |