OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2400 | 2400 |
2401 | 2401 |
2402 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 2402 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
2403 CEntryStub stub(1, kDontSaveFPRegs); | 2403 CEntryStub stub(1, kDontSaveFPRegs); |
2404 stub.GetCode(isolate); | 2404 stub.GetCode(isolate); |
2405 CEntryStub save_doubles(1, kSaveFPRegs); | 2405 CEntryStub save_doubles(1, kSaveFPRegs); |
2406 save_doubles.GetCode(isolate); | 2406 save_doubles.GetCode(isolate); |
2407 } | 2407 } |
2408 | 2408 |
2409 | 2409 |
2410 static void JumpIfOOM(MacroAssembler* masm, | |
2411 Register value, | |
2412 Register scratch, | |
2413 Label* oom_label) { | |
2414 __ movp(scratch, value); | |
2415 STATIC_ASSERT(Failure::OUT_OF_MEMORY_EXCEPTION == 3); | |
2416 STATIC_ASSERT(kFailureTag == 3); | |
2417 __ and_(scratch, Immediate(0xf)); | |
2418 __ cmpq(scratch, Immediate(0xf)); | |
2419 __ j(equal, oom_label); | |
2420 } | |
2421 | |
2422 | |
2423 void CEntryStub::GenerateCore(MacroAssembler* masm, | 2410 void CEntryStub::GenerateCore(MacroAssembler* masm, |
2424 Label* throw_normal_exception, | 2411 Label* throw_normal_exception, |
2425 Label* throw_termination_exception, | 2412 Label* throw_termination_exception, |
2426 Label* throw_out_of_memory_exception, | |
2427 bool do_gc, | 2413 bool do_gc, |
2428 bool always_allocate_scope) { | 2414 bool always_allocate_scope) { |
2429 // rax: result parameter for PerformGC, if any. | 2415 // rax: result parameter for PerformGC, if any. |
2430 // rbx: pointer to C function (C callee-saved). | 2416 // rbx: pointer to C function (C callee-saved). |
2431 // rbp: frame pointer (restored after C call). | 2417 // rbp: frame pointer (restored after C call). |
2432 // rsp: stack pointer (restored after C call). | 2418 // rsp: stack pointer (restored after C call). |
2433 // r14: number of arguments including receiver (C callee-saved). | 2419 // r14: number of arguments including receiver (C callee-saved). |
2434 // r15: pointer to the first argument (C callee-saved). | 2420 // r15: pointer to the first argument (C callee-saved). |
2435 // This pointer is reused in LeaveExitFrame(), so it is stored in a | 2421 // This pointer is reused in LeaveExitFrame(), so it is stored in a |
2436 // callee-saved register. | 2422 // callee-saved register. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 | 2509 |
2524 // Handling of failure. | 2510 // Handling of failure. |
2525 __ bind(&failure_returned); | 2511 __ bind(&failure_returned); |
2526 | 2512 |
2527 Label retry; | 2513 Label retry; |
2528 // If the returned exception is RETRY_AFTER_GC continue at retry label | 2514 // If the returned exception is RETRY_AFTER_GC continue at retry label |
2529 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); | 2515 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); |
2530 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); | 2516 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); |
2531 __ j(zero, &retry, Label::kNear); | 2517 __ j(zero, &retry, Label::kNear); |
2532 | 2518 |
2533 // Special handling of out of memory exceptions. | |
2534 JumpIfOOM(masm, rax, kScratchRegister, throw_out_of_memory_exception); | |
2535 | |
2536 // Retrieve the pending exception. | 2519 // Retrieve the pending exception. |
2537 ExternalReference pending_exception_address( | 2520 ExternalReference pending_exception_address( |
2538 Isolate::kPendingExceptionAddress, masm->isolate()); | 2521 Isolate::kPendingExceptionAddress, masm->isolate()); |
2539 Operand pending_exception_operand = | 2522 Operand pending_exception_operand = |
2540 masm->ExternalOperand(pending_exception_address); | 2523 masm->ExternalOperand(pending_exception_address); |
2541 __ movp(rax, pending_exception_operand); | 2524 __ movp(rax, pending_exception_operand); |
2542 | 2525 |
2543 // See if we just retrieved an OOM exception. | |
2544 JumpIfOOM(masm, rax, kScratchRegister, throw_out_of_memory_exception); | |
2545 | |
2546 // Clear the pending exception. | 2526 // Clear the pending exception. |
2547 pending_exception_operand = | 2527 pending_exception_operand = |
2548 masm->ExternalOperand(pending_exception_address); | 2528 masm->ExternalOperand(pending_exception_address); |
2549 __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex); | 2529 __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex); |
2550 __ movp(pending_exception_operand, rdx); | 2530 __ movp(pending_exception_operand, rdx); |
2551 | 2531 |
2552 // Special handling of termination exceptions which are uncatchable | 2532 // Special handling of termination exceptions which are uncatchable |
2553 // by javascript code. | 2533 // by javascript code. |
2554 __ CompareRoot(rax, Heap::kTerminationExceptionRootIndex); | 2534 __ CompareRoot(rax, Heap::kTerminationExceptionRootIndex); |
2555 __ j(equal, throw_termination_exception); | 2535 __ j(equal, throw_termination_exception); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 // generated by a previous call to GenerateCore. The value | 2571 // generated by a previous call to GenerateCore. The value |
2592 // of rax is then passed to Runtime::PerformGC. | 2572 // of rax is then passed to Runtime::PerformGC. |
2593 // rbx: pointer to builtin function (C callee-saved). | 2573 // rbx: pointer to builtin function (C callee-saved). |
2594 // rbp: frame pointer of exit frame (restored after C call). | 2574 // rbp: frame pointer of exit frame (restored after C call). |
2595 // rsp: stack pointer (restored after C call). | 2575 // rsp: stack pointer (restored after C call). |
2596 // r14: number of arguments including receiver (C callee-saved). | 2576 // r14: number of arguments including receiver (C callee-saved). |
2597 // r15: argv pointer (C callee-saved). | 2577 // r15: argv pointer (C callee-saved). |
2598 | 2578 |
2599 Label throw_normal_exception; | 2579 Label throw_normal_exception; |
2600 Label throw_termination_exception; | 2580 Label throw_termination_exception; |
2601 Label throw_out_of_memory_exception; | |
2602 | 2581 |
2603 // Call into the runtime system. | 2582 // Call into the runtime system. |
2604 GenerateCore(masm, | 2583 GenerateCore(masm, |
2605 &throw_normal_exception, | 2584 &throw_normal_exception, |
2606 &throw_termination_exception, | 2585 &throw_termination_exception, |
2607 &throw_out_of_memory_exception, | |
2608 false, | 2586 false, |
2609 false); | 2587 false); |
2610 | 2588 |
2611 // Do space-specific GC and retry runtime call. | 2589 // Do space-specific GC and retry runtime call. |
2612 GenerateCore(masm, | 2590 GenerateCore(masm, |
2613 &throw_normal_exception, | 2591 &throw_normal_exception, |
2614 &throw_termination_exception, | 2592 &throw_termination_exception, |
2615 &throw_out_of_memory_exception, | |
2616 true, | 2593 true, |
2617 false); | 2594 false); |
2618 | 2595 |
2619 // Do full GC and retry runtime call one final time. | 2596 // Do full GC and retry runtime call one final time. |
2620 Failure* failure = Failure::InternalError(); | 2597 Failure* failure = Failure::InternalError(); |
2621 __ Move(rax, failure, Assembler::RelocInfoNone()); | 2598 __ Move(rax, failure, Assembler::RelocInfoNone()); |
2622 GenerateCore(masm, | 2599 GenerateCore(masm, |
2623 &throw_normal_exception, | 2600 &throw_normal_exception, |
2624 &throw_termination_exception, | 2601 &throw_termination_exception, |
2625 &throw_out_of_memory_exception, | |
2626 true, | 2602 true, |
2627 true); | 2603 true); |
2628 | 2604 |
2629 __ bind(&throw_out_of_memory_exception); | |
2630 // Set external caught exception to false. | |
2631 Isolate* isolate = masm->isolate(); | |
2632 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, | |
2633 isolate); | |
2634 __ Set(rax, static_cast<int64_t>(false)); | |
2635 __ Store(external_caught, rax); | |
2636 | |
2637 // Set pending exception and rax to out of memory exception. | |
2638 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, | |
2639 isolate); | |
2640 Label already_have_failure; | |
2641 JumpIfOOM(masm, rax, kScratchRegister, &already_have_failure); | |
2642 __ Move(rax, Failure::OutOfMemoryException(0x1), Assembler::RelocInfoNone()); | |
2643 __ bind(&already_have_failure); | |
2644 __ Store(pending_exception, rax); | |
2645 // Fall through to the next label. | |
2646 | |
2647 __ bind(&throw_termination_exception); | 2605 __ bind(&throw_termination_exception); |
2648 __ ThrowUncatchable(rax); | 2606 __ ThrowUncatchable(rax); |
2649 | 2607 |
2650 __ bind(&throw_normal_exception); | 2608 __ bind(&throw_normal_exception); |
2651 __ Throw(rax); | 2609 __ Throw(rax); |
2652 } | 2610 } |
2653 | 2611 |
2654 | 2612 |
2655 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 2613 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
2656 Label invoke, handler_entry, exit; | 2614 Label invoke, handler_entry, exit; |
(...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5256 return_value_operand, | 5214 return_value_operand, |
5257 NULL); | 5215 NULL); |
5258 } | 5216 } |
5259 | 5217 |
5260 | 5218 |
5261 #undef __ | 5219 #undef __ |
5262 | 5220 |
5263 } } // namespace v8::internal | 5221 } } // namespace v8::internal |
5264 | 5222 |
5265 #endif // V8_TARGET_ARCH_X64 | 5223 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |