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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
8 #include "src/ast/compile-time-value.h" | 8 #include "src/ast/compile-time-value.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3326 // context calling eval, not the anonymous closure containing the eval | 3326 // context calling eval, not the anonymous closure containing the eval |
3327 // code. Fetch it from the context. | 3327 // code. Fetch it from the context. |
3328 PushOperand(ContextOperand(rsi, Context::CLOSURE_INDEX)); | 3328 PushOperand(ContextOperand(rsi, Context::CLOSURE_INDEX)); |
3329 } else { | 3329 } else { |
3330 DCHECK(closure_scope->is_function_scope()); | 3330 DCHECK(closure_scope->is_function_scope()); |
3331 PushOperand(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 3331 PushOperand(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
3332 } | 3332 } |
3333 } | 3333 } |
3334 | 3334 |
3335 | 3335 |
3336 // ---------------------------------------------------------------------------- | |
3337 // Non-local control flow support. | |
3338 | |
3339 | |
3340 void FullCodeGenerator::EnterFinallyBlock() { | |
3341 DCHECK(!result_register().is(rdx)); | |
3342 | |
3343 // Store pending message while executing finally block. | |
3344 ExternalReference pending_message_obj = | |
3345 ExternalReference::address_of_pending_message_obj(isolate()); | |
3346 __ Load(rdx, pending_message_obj); | |
3347 PushOperand(rdx); | |
3348 | |
3349 ClearPendingMessage(); | |
3350 } | |
3351 | |
3352 | |
3353 void FullCodeGenerator::ExitFinallyBlock() { | |
3354 DCHECK(!result_register().is(rdx)); | |
3355 // Restore pending message from stack. | |
3356 PopOperand(rdx); | |
3357 ExternalReference pending_message_obj = | |
3358 ExternalReference::address_of_pending_message_obj(isolate()); | |
3359 __ Store(pending_message_obj, rdx); | |
3360 } | |
3361 | |
3362 | |
3363 void FullCodeGenerator::ClearPendingMessage() { | |
3364 DCHECK(!result_register().is(rdx)); | |
3365 ExternalReference pending_message_obj = | |
3366 ExternalReference::address_of_pending_message_obj(isolate()); | |
3367 __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex); | |
3368 __ Store(pending_message_obj, rdx); | |
3369 } | |
3370 | |
3371 | |
3372 void FullCodeGenerator::DeferredCommands::EmitCommands() { | |
3373 __ Pop(result_register()); // Restore the accumulator. | |
3374 __ Pop(rdx); // Get the token. | |
3375 for (DeferredCommand cmd : commands_) { | |
3376 Label skip; | |
3377 __ SmiCompare(rdx, Smi::FromInt(cmd.token)); | |
3378 __ j(not_equal, &skip); | |
3379 switch (cmd.command) { | |
3380 case kReturn: | |
3381 codegen_->EmitUnwindAndReturn(); | |
3382 break; | |
3383 case kThrow: | |
3384 __ Push(result_register()); | |
3385 __ CallRuntime(Runtime::kReThrow); | |
3386 break; | |
3387 case kContinue: | |
3388 codegen_->EmitContinue(cmd.target); | |
3389 break; | |
3390 case kBreak: | |
3391 codegen_->EmitBreak(cmd.target); | |
3392 break; | |
3393 } | |
3394 __ bind(&skip); | |
3395 } | |
3396 } | |
3397 | |
3398 #undef __ | 3336 #undef __ |
3399 | 3337 |
3400 | 3338 |
3401 static const byte kJnsInstruction = 0x79; | 3339 static const byte kJnsInstruction = 0x79; |
3402 static const byte kNopByteOne = 0x66; | 3340 static const byte kNopByteOne = 0x66; |
3403 static const byte kNopByteTwo = 0x90; | 3341 static const byte kNopByteTwo = 0x90; |
3404 #ifdef DEBUG | 3342 #ifdef DEBUG |
3405 static const byte kCallInstruction = 0xe8; | 3343 static const byte kCallInstruction = 0xe8; |
3406 #endif | 3344 #endif |
3407 | 3345 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3464 DCHECK_EQ( | 3402 DCHECK_EQ( |
3465 isolate->builtins()->OnStackReplacement()->entry(), | 3403 isolate->builtins()->OnStackReplacement()->entry(), |
3466 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3404 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3467 return ON_STACK_REPLACEMENT; | 3405 return ON_STACK_REPLACEMENT; |
3468 } | 3406 } |
3469 | 3407 |
3470 } // namespace internal | 3408 } // namespace internal |
3471 } // namespace v8 | 3409 } // namespace v8 |
3472 | 3410 |
3473 #endif // V8_TARGET_ARCH_X64 | 3411 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |