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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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, 5 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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 __ pushl(registers_[i]); 36 __ pushl(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 __ leal(ESP,
43 Address(EBP, 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 =
srdjan 2012/07/25 17:25:52 s/int/intptr_t/
46 ParsedFunction::kFirstLocalSlotIndex - values.length();
47 __ leal(ESP, Address(EBP, top_offset * kWordSize));
46 48
49 // 2. Build and emit a parallel move representing the frame translation.
50 ParallelMoveInstr* move = new ParallelMoveInstr();
47 for (intptr_t i = 0; i < values.length(); i++) { 51 for (intptr_t i = 0; i < values.length(); i++) {
48 const Location loc = deoptimization_env_->LocationAt(i); 52 Location destination = Location::SpillSlot(i);
49 if (loc.IsInvalid()) { 53 Location source = deoptimization_env_->LocationAt(i);
50 ASSERT(values[i]->IsConstant()); 54 if (!source.IsRegister() && !source.IsInvalid()) {
51 __ PushObject(values[i]->AsConstant()->value());
52 } else if (loc.IsRegister()) {
53 __ pushl(loc.reg());
54 } else {
55 compiler->Bailout("unsupported deoptimization state"); 55 compiler->Bailout("unsupported deoptimization state");
56 } 56 }
57 if (source.IsInvalid()) {
58 ASSERT(values[i]->IsConstant());
59 source = Location::Constant(values[i]->AsConstant()->value());
60 }
61 move->AddMove(destination, source);
57 } 62 }
63 compiler->parallel_move_resolver()->EmitNativeCode(move);
58 } 64 }
59 65
60 if (compiler->IsLeaf()) { 66 if (compiler->IsLeaf()) {
61 Label L; 67 Label L;
62 __ call(&L); 68 __ call(&L);
63 const intptr_t offset = assem->CodeSize(); 69 const intptr_t offset = assem->CodeSize();
64 __ Bind(&L); 70 __ Bind(&L);
65 __ popl(EAX); 71 __ popl(EAX);
66 __ subl(EAX, 72 __ subl(EAX,
67 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); 73 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint));
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 __ popl(ECX); 1233 __ popl(ECX);
1228 __ popl(EAX); 1234 __ popl(EAX);
1229 } 1235 }
1230 1236
1231 1237
1232 #undef __ 1238 #undef __
1233 1239
1234 } // namespace dart 1240 } // namespace dart
1235 1241
1236 #endif // defined TARGET_ARCH_IA32 1242 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698