Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 2357343003: Fix lazy deoptimization in the presence of exceptions (Closed)
Patch Set: Ensure space for patching on ARM/MIPS archs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/simulator_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
11 #include "vm/dart_entry.h" 11 #include "vm/dart_entry.h"
12 #include "vm/flow_graph.h" 12 #include "vm/flow_graph.h"
13 #include "vm/flow_graph_compiler.h" 13 #include "vm/flow_graph_compiler.h"
14 #include "vm/flow_graph_range_analysis.h" 14 #include "vm/flow_graph_range_analysis.h"
15 #include "vm/instructions.h"
15 #include "vm/locations.h" 16 #include "vm/locations.h"
16 #include "vm/object_store.h" 17 #include "vm/object_store.h"
17 #include "vm/parser.h" 18 #include "vm/parser.h"
18 #include "vm/stack_frame.h" 19 #include "vm/stack_frame.h"
19 #include "vm/stub_code.h" 20 #include "vm/stub_code.h"
20 #include "vm/symbols.h" 21 #include "vm/symbols.h"
21 22
22 #define __ compiler->assembler()-> 23 #define __ compiler->assembler()->
23 #define Z (compiler->zone()) 24 #define Z (compiler->zone())
24 25
(...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 2557
2557 2558
2558 LocationSummary* CatchBlockEntryInstr::MakeLocationSummary(Zone* zone, 2559 LocationSummary* CatchBlockEntryInstr::MakeLocationSummary(Zone* zone,
2559 bool opt) const { 2560 bool opt) const {
2560 UNREACHABLE(); 2561 UNREACHABLE();
2561 return NULL; 2562 return NULL;
2562 } 2563 }
2563 2564
2564 2565
2565 void CatchBlockEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2566 void CatchBlockEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2567 // Ensure space for patching return sites for lazy deopt.
2568 if (!FLAG_precompiled_mode && compiler->is_optimizing()) {
2569 __ nop(ShortCallPattern::pattern_length_in_bytes());
2570 }
2566 __ Bind(compiler->GetJumpLabel(this)); 2571 __ Bind(compiler->GetJumpLabel(this));
2567 compiler->AddExceptionHandler(catch_try_index(), 2572 compiler->AddExceptionHandler(catch_try_index(),
2568 try_index(), 2573 try_index(),
2569 compiler->assembler()->CodeSize(), 2574 compiler->assembler()->CodeSize(),
2570 catch_handler_types_, 2575 catch_handler_types_,
2571 needs_stacktrace()); 2576 needs_stacktrace());
2572 2577 // On lazy deoptimization we patch the optimized code here to enter the
2573 // Restore the pool pointer. 2578 // deoptimization stub.
2574 __ RestoreCodePointer(); 2579 const intptr_t deopt_id = Thread::ToDeoptAfter(GetDeoptId());
2575 __ LoadPoolPointer(PP); 2580 if (compiler->is_optimizing()) {
2576 2581 compiler->AddDeoptIndexAtCall(deopt_id);
2582 } else {
2583 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt,
2584 deopt_id,
2585 TokenPosition::kNoSource);
2586 }
2577 if (HasParallelMove()) { 2587 if (HasParallelMove()) {
2578 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 2588 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
2579 } 2589 }
2580 2590
2581 // Restore RSP from RBP as we are coming from a throw and the code for 2591 // Restore RSP from RBP as we are coming from a throw and the code for
2582 // popping arguments has not been run. 2592 // popping arguments has not been run.
2583 const intptr_t fp_sp_dist = 2593 const intptr_t fp_sp_dist =
2584 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; 2594 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize;
2585 ASSERT(fp_sp_dist <= 0); 2595 ASSERT(fp_sp_dist <= 0);
2586 __ leaq(RSP, Address(RBP, fp_sp_dist)); 2596 __ leaq(RSP, Address(RBP, fp_sp_dist));
(...skipping 3913 matching lines...) Expand 10 before | Expand all | Expand 10 after
6500 // RAX: Function. 6510 // RAX: Function.
6501 // R10: Arguments descriptor array. 6511 // R10: Arguments descriptor array.
6502 // RBX: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value). 6512 // RBX: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value).
6503 __ xorq(RBX, RBX); 6513 __ xorq(RBX, RBX);
6504 __ call(RCX); 6514 __ call(RCX);
6505 compiler->RecordSafepoint(locs()); 6515 compiler->RecordSafepoint(locs());
6506 // Marks either the continuation point in unoptimized code or the 6516 // Marks either the continuation point in unoptimized code or the
6507 // deoptimization point in optimized code, after call. 6517 // deoptimization point in optimized code, after call.
6508 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id()); 6518 const intptr_t deopt_id_after = Thread::ToDeoptAfter(deopt_id());
6509 if (compiler->is_optimizing()) { 6519 if (compiler->is_optimizing()) {
6510 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); 6520 compiler->AddDeoptIndexAtCall(deopt_id_after);
6511 } 6521 }
6512 // Add deoptimization continuation point after the call and before the 6522 // Add deoptimization continuation point after the call and before the
6513 // arguments are removed. 6523 // arguments are removed.
6514 // In optimized code this descriptor is needed for exception handling. 6524 // In optimized code this descriptor is needed for exception handling.
6515 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, 6525 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt,
6516 deopt_id_after, 6526 deopt_id_after,
6517 token_pos()); 6527 token_pos());
6518 __ Drop(argument_count); 6528 __ Drop(argument_count);
6519 } 6529 }
6520 6530
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
6593 __ Drop(1); 6603 __ Drop(1);
6594 __ popq(result); 6604 __ popq(result);
6595 } 6605 }
6596 6606
6597 6607
6598 } // namespace dart 6608 } // namespace dart
6599 6609
6600 #undef __ 6610 #undef __
6601 6611
6602 #endif // defined TARGET_ARCH_X64 6612 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/simulator_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698