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 |
2410 void CEntryStub::GenerateCore(MacroAssembler* masm, | 2423 void CEntryStub::GenerateCore(MacroAssembler* masm, |
2411 Label* throw_normal_exception, | 2424 Label* throw_normal_exception, |
2412 Label* throw_termination_exception, | 2425 Label* throw_termination_exception, |
| 2426 Label* throw_out_of_memory_exception, |
2413 bool do_gc, | 2427 bool do_gc, |
2414 bool always_allocate_scope) { | 2428 bool always_allocate_scope) { |
2415 // rax: result parameter for PerformGC, if any. | 2429 // rax: result parameter for PerformGC, if any. |
2416 // rbx: pointer to C function (C callee-saved). | 2430 // rbx: pointer to C function (C callee-saved). |
2417 // rbp: frame pointer (restored after C call). | 2431 // rbp: frame pointer (restored after C call). |
2418 // rsp: stack pointer (restored after C call). | 2432 // rsp: stack pointer (restored after C call). |
2419 // r14: number of arguments including receiver (C callee-saved). | 2433 // r14: number of arguments including receiver (C callee-saved). |
2420 // r15: pointer to the first argument (C callee-saved). | 2434 // r15: pointer to the first argument (C callee-saved). |
2421 // This pointer is reused in LeaveExitFrame(), so it is stored in a | 2435 // This pointer is reused in LeaveExitFrame(), so it is stored in a |
2422 // callee-saved register. | 2436 // callee-saved register. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 | 2523 |
2510 // Handling of failure. | 2524 // Handling of failure. |
2511 __ bind(&failure_returned); | 2525 __ bind(&failure_returned); |
2512 | 2526 |
2513 Label retry; | 2527 Label retry; |
2514 // If the returned exception is RETRY_AFTER_GC continue at retry label | 2528 // If the returned exception is RETRY_AFTER_GC continue at retry label |
2515 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); | 2529 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); |
2516 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); | 2530 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); |
2517 __ j(zero, &retry, Label::kNear); | 2531 __ j(zero, &retry, Label::kNear); |
2518 | 2532 |
| 2533 // Special handling of out of memory exceptions. |
| 2534 JumpIfOOM(masm, rax, kScratchRegister, throw_out_of_memory_exception); |
| 2535 |
2519 // Retrieve the pending exception. | 2536 // Retrieve the pending exception. |
2520 ExternalReference pending_exception_address( | 2537 ExternalReference pending_exception_address( |
2521 Isolate::kPendingExceptionAddress, masm->isolate()); | 2538 Isolate::kPendingExceptionAddress, masm->isolate()); |
2522 Operand pending_exception_operand = | 2539 Operand pending_exception_operand = |
2523 masm->ExternalOperand(pending_exception_address); | 2540 masm->ExternalOperand(pending_exception_address); |
2524 __ movp(rax, pending_exception_operand); | 2541 __ movp(rax, pending_exception_operand); |
2525 | 2542 |
| 2543 // See if we just retrieved an OOM exception. |
| 2544 JumpIfOOM(masm, rax, kScratchRegister, throw_out_of_memory_exception); |
| 2545 |
2526 // Clear the pending exception. | 2546 // Clear the pending exception. |
2527 pending_exception_operand = | 2547 pending_exception_operand = |
2528 masm->ExternalOperand(pending_exception_address); | 2548 masm->ExternalOperand(pending_exception_address); |
2529 __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex); | 2549 __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex); |
2530 __ movp(pending_exception_operand, rdx); | 2550 __ movp(pending_exception_operand, rdx); |
2531 | 2551 |
2532 // Special handling of termination exceptions which are uncatchable | 2552 // Special handling of termination exceptions which are uncatchable |
2533 // by javascript code. | 2553 // by javascript code. |
2534 __ CompareRoot(rax, Heap::kTerminationExceptionRootIndex); | 2554 __ CompareRoot(rax, Heap::kTerminationExceptionRootIndex); |
2535 __ j(equal, throw_termination_exception); | 2555 __ j(equal, throw_termination_exception); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 // generated by a previous call to GenerateCore. The value | 2591 // generated by a previous call to GenerateCore. The value |
2572 // of rax is then passed to Runtime::PerformGC. | 2592 // of rax is then passed to Runtime::PerformGC. |
2573 // rbx: pointer to builtin function (C callee-saved). | 2593 // rbx: pointer to builtin function (C callee-saved). |
2574 // rbp: frame pointer of exit frame (restored after C call). | 2594 // rbp: frame pointer of exit frame (restored after C call). |
2575 // rsp: stack pointer (restored after C call). | 2595 // rsp: stack pointer (restored after C call). |
2576 // r14: number of arguments including receiver (C callee-saved). | 2596 // r14: number of arguments including receiver (C callee-saved). |
2577 // r15: argv pointer (C callee-saved). | 2597 // r15: argv pointer (C callee-saved). |
2578 | 2598 |
2579 Label throw_normal_exception; | 2599 Label throw_normal_exception; |
2580 Label throw_termination_exception; | 2600 Label throw_termination_exception; |
| 2601 Label throw_out_of_memory_exception; |
2581 | 2602 |
2582 // Call into the runtime system. | 2603 // Call into the runtime system. |
2583 GenerateCore(masm, | 2604 GenerateCore(masm, |
2584 &throw_normal_exception, | 2605 &throw_normal_exception, |
2585 &throw_termination_exception, | 2606 &throw_termination_exception, |
| 2607 &throw_out_of_memory_exception, |
2586 false, | 2608 false, |
2587 false); | 2609 false); |
2588 | 2610 |
2589 // Do space-specific GC and retry runtime call. | 2611 // Do space-specific GC and retry runtime call. |
2590 GenerateCore(masm, | 2612 GenerateCore(masm, |
2591 &throw_normal_exception, | 2613 &throw_normal_exception, |
2592 &throw_termination_exception, | 2614 &throw_termination_exception, |
| 2615 &throw_out_of_memory_exception, |
2593 true, | 2616 true, |
2594 false); | 2617 false); |
2595 | 2618 |
2596 // Do full GC and retry runtime call one final time. | 2619 // Do full GC and retry runtime call one final time. |
2597 Failure* failure = Failure::InternalError(); | 2620 Failure* failure = Failure::InternalError(); |
2598 __ Move(rax, failure, Assembler::RelocInfoNone()); | 2621 __ Move(rax, failure, Assembler::RelocInfoNone()); |
2599 GenerateCore(masm, | 2622 GenerateCore(masm, |
2600 &throw_normal_exception, | 2623 &throw_normal_exception, |
2601 &throw_termination_exception, | 2624 &throw_termination_exception, |
| 2625 &throw_out_of_memory_exception, |
2602 true, | 2626 true, |
2603 true); | 2627 true); |
2604 | 2628 |
| 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 |
2605 __ bind(&throw_termination_exception); | 2647 __ bind(&throw_termination_exception); |
2606 __ ThrowUncatchable(rax); | 2648 __ ThrowUncatchable(rax); |
2607 | 2649 |
2608 __ bind(&throw_normal_exception); | 2650 __ bind(&throw_normal_exception); |
2609 __ Throw(rax); | 2651 __ Throw(rax); |
2610 } | 2652 } |
2611 | 2653 |
2612 | 2654 |
2613 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 2655 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
2614 Label invoke, handler_entry, exit; | 2656 Label invoke, handler_entry, exit; |
(...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5214 return_value_operand, | 5256 return_value_operand, |
5215 NULL); | 5257 NULL); |
5216 } | 5258 } |
5217 | 5259 |
5218 | 5260 |
5219 #undef __ | 5261 #undef __ |
5220 | 5262 |
5221 } } // namespace v8::internal | 5263 } } // namespace v8::internal |
5222 | 5264 |
5223 #endif // V8_TARGET_ARCH_X64 | 5265 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |