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

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

Issue 10824017: Implement deoptimization in the SSA compiler as a parallel move. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 19 matching lines...) Expand all
30 __ Comment("Deopt stub for id %d", deopt_id_); 30 __ Comment("Deopt stub for id %d", deopt_id_);
31 __ Bind(entry_label()); 31 __ Bind(entry_label());
32 32
33 if (deoptimization_env_ == NULL) { 33 if (deoptimization_env_ == NULL) {
34 for (intptr_t i = 0; i < registers_.length(); i++) { 34 for (intptr_t i = 0; i < registers_.length(); i++) {
35 if (registers_[i] != kNoRegister) { 35 if (registers_[i] != kNoRegister) {
36 __ pushq(registers_[i]); 36 __ pushq(registers_[i]);
37 } 37 }
38 } 38 }
39 } else { 39 } else {
40 // We have a deoptimization environment, we have to tear down optimized 40 // We have a deoptimization environment, we have to tear down the
41 // frame and recreate non-optimized one. 41 // optimized frame and recreate a non-optimized one.
42 __ leaq(RSP,
43 Address(RBP, ParsedFunction::kFirstLocalSlotIndex * kWordSize));
44 42
43 // 1. Set the stack pointer to the top of the non-optimized frame.
45 const GrowableArray<Value*>& values = deoptimization_env_->values(); 44 const GrowableArray<Value*>& values = deoptimization_env_->values();
45 const int top_offset =
46 ParsedFunction::kFirstLocalSlotIndex - values.length();
Vyacheslav Egorov (Google) 2012/07/26 12:59:56 this should have been actually ParsedFunction::kFi
47 __ leaq(RSP, Address(RBP, top_offset * kWordSize));
48
49 // 2. Build and emit a parallel move representing the frame translation.
50 ParallelMoveInstr* move = new ParallelMoveInstr();
46 for (intptr_t i = 0; i < values.length(); i++) { 51 for (intptr_t i = 0; i < values.length(); i++) {
47 const Location loc = deoptimization_env_->LocationAt(i); 52 Location destination = Location::SpillSlot(i);
48 if (loc.IsInvalid()) { 53 Location source = deoptimization_env_->LocationAt(i);
49 ASSERT(values[i]->IsConstant()); 54 if (!source.IsRegister() && !source.IsInvalid()) {
50 __ PushObject(values[i]->AsConstant()->value());
51 } else if (loc.IsRegister()) {
52 __ pushq(loc.reg());
53 } else {
54 compiler->Bailout("unsupported deoptimization state"); 55 compiler->Bailout("unsupported deoptimization state");
55 } 56 }
57 if (source.IsInvalid()) {
58 ASSERT(values[i]->IsConstant());
59 source = Location::Constant(values[i]->AsConstant()->value());
60 }
61 move->AddMove(destination, source);
56 } 62 }
63 compiler->parallel_move_resolver()->EmitNativeCode(move);
57 } 64 }
58 65
59 if (compiler->IsLeaf()) { 66 if (compiler->IsLeaf()) {
60 Label L; 67 Label L;
61 __ call(&L); 68 __ call(&L);
62 const intptr_t offset = assem->CodeSize(); 69 const intptr_t offset = assem->CodeSize();
63 __ Bind(&L); 70 __ Bind(&L);
64 __ popq(RAX); 71 __ popq(RAX);
65 __ subq(RAX, 72 __ subq(RAX,
66 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); 73 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint));
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { 1214 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) {
1208 __ Exchange(mem1, mem2); 1215 __ Exchange(mem1, mem2);
1209 } 1216 }
1210 1217
1211 1218
1212 #undef __ 1219 #undef __
1213 1220
1214 } // namespace dart 1221 } // namespace dart
1215 1222
1216 #endif // defined TARGET_ARCH_X64 1223 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698