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

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

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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
« no previous file with comments | « runtime/vm/debugger_api_impl_test.cc ('k') | runtime/vm/disassembler.h » ('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) 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/deopt_instructions.h" 5 #include "vm/deopt_instructions.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 #include "vm/locations.h" 9 #include "vm/locations.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 public: 48 public:
49 explicit DeoptStackSlotInstr(intptr_t from_index) 49 explicit DeoptStackSlotInstr(intptr_t from_index)
50 : stack_slot_index_(from_index) { 50 : stack_slot_index_(from_index) {
51 ASSERT(stack_slot_index_ >= 0); 51 ASSERT(stack_slot_index_ >= 0);
52 } 52 }
53 53
54 virtual intptr_t from_index() const { return stack_slot_index_; } 54 virtual intptr_t from_index() const { return stack_slot_index_; }
55 virtual DeoptInstr::Kind kind() const { return kCopyStackSlot; } 55 virtual DeoptInstr::Kind kind() const { return kCopyStackSlot; }
56 56
57 virtual const char* ToCString() const { 57 virtual const char* ToCString() const {
58 intptr_t len = OS::SNPrint(NULL, 0, "s%d", stack_slot_index_); 58 const char* format = "s%"Pd"";
59 intptr_t len = OS::SNPrint(NULL, 0, format, stack_slot_index_);
59 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 60 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
60 OS::SNPrint(chars, len + 1, "s%d", stack_slot_index_); 61 OS::SNPrint(chars, len + 1, format, stack_slot_index_);
61 return chars; 62 return chars;
62 } 63 }
63 64
64 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { 65 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
65 intptr_t from_index = 66 intptr_t from_index =
66 deopt_context->from_frame_size() - stack_slot_index_ - 1; 67 deopt_context->from_frame_size() - stack_slot_index_ - 1;
67 intptr_t* from_addr = deopt_context->GetFromFrameAddressAt(from_index); 68 intptr_t* from_addr = deopt_context->GetFromFrameAddressAt(from_index);
68 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); 69 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index);
69 *to_addr = *from_addr; 70 *to_addr = *from_addr;
70 } 71 }
71 72
72 private: 73 private:
73 const intptr_t stack_slot_index_; // First argument is 0, always >= 0. 74 const intptr_t stack_slot_index_; // First argument is 0, always >= 0.
74 75
75 DISALLOW_COPY_AND_ASSIGN(DeoptStackSlotInstr); 76 DISALLOW_COPY_AND_ASSIGN(DeoptStackSlotInstr);
76 }; 77 };
77 78
78 79
79 class DeoptDoubleStackSlotInstr : public DeoptInstr { 80 class DeoptDoubleStackSlotInstr : public DeoptInstr {
80 public: 81 public:
81 explicit DeoptDoubleStackSlotInstr(intptr_t from_index) 82 explicit DeoptDoubleStackSlotInstr(intptr_t from_index)
82 : stack_slot_index_(from_index) { 83 : stack_slot_index_(from_index) {
83 ASSERT(stack_slot_index_ >= 0); 84 ASSERT(stack_slot_index_ >= 0);
84 } 85 }
85 86
86 virtual intptr_t from_index() const { return stack_slot_index_; } 87 virtual intptr_t from_index() const { return stack_slot_index_; }
87 virtual DeoptInstr::Kind kind() const { return kCopyDoubleStackSlot; } 88 virtual DeoptInstr::Kind kind() const { return kCopyDoubleStackSlot; }
88 89
89 virtual const char* ToCString() const { 90 virtual const char* ToCString() const {
90 intptr_t len = OS::SNPrint(NULL, 0, "ds%d", stack_slot_index_); 91 const char* format = "ds%"Pd"";
92 intptr_t len = OS::SNPrint(NULL, 0, format, stack_slot_index_);
91 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 93 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
92 OS::SNPrint(chars, len + 1, "ds%d", stack_slot_index_); 94 OS::SNPrint(chars, len + 1, format, stack_slot_index_);
93 return chars; 95 return chars;
94 } 96 }
95 97
96 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { 98 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
97 intptr_t from_index = 99 intptr_t from_index =
98 deopt_context->from_frame_size() - stack_slot_index_ - 1; 100 deopt_context->from_frame_size() - stack_slot_index_ - 1;
99 double* from_addr = reinterpret_cast<double*>( 101 double* from_addr = reinterpret_cast<double*>(
100 deopt_context->GetFromFrameAddressAt(from_index)); 102 deopt_context->GetFromFrameAddressAt(from_index));
101 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); 103 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index);
102 *reinterpret_cast<RawSmi**>(to_addr) = Smi::New(0); 104 *reinterpret_cast<RawSmi**>(to_addr) = Smi::New(0);
(...skipping 15 matching lines...) Expand all
118 public: 120 public:
119 explicit DeoptRetAddrAfterInstr(intptr_t object_table_index) 121 explicit DeoptRetAddrAfterInstr(intptr_t object_table_index)
120 : object_table_index_(object_table_index) { 122 : object_table_index_(object_table_index) {
121 ASSERT(object_table_index >= 0); 123 ASSERT(object_table_index >= 0);
122 } 124 }
123 125
124 virtual intptr_t from_index() const { return object_table_index_; } 126 virtual intptr_t from_index() const { return object_table_index_; }
125 virtual DeoptInstr::Kind kind() const { return kSetRetAfterAddress; } 127 virtual DeoptInstr::Kind kind() const { return kSetRetAfterAddress; }
126 128
127 virtual const char* ToCString() const { 129 virtual const char* ToCString() const {
128 intptr_t len = OS::SNPrint(NULL, 0, "ret aft oti:%d", object_table_index_); 130 const char* format = "ret aft oti:%"Pd"";
131 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_);
129 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 132 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
130 OS::SNPrint(chars, len + 1, "ret aft oti:%d", object_table_index_); 133 OS::SNPrint(chars, len + 1, format, object_table_index_);
131 return chars; 134 return chars;
132 } 135 }
133 136
134 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { 137 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
135 Function& function = Function::Handle(deopt_context->isolate()); 138 Function& function = Function::Handle(deopt_context->isolate());
136 function ^= deopt_context->ObjectAt(object_table_index_); 139 function ^= deopt_context->ObjectAt(object_table_index_);
137 Smi& deopt_id_as_smi = Smi::Handle(deopt_context->isolate()); 140 Smi& deopt_id_as_smi = Smi::Handle(deopt_context->isolate());
138 deopt_id_as_smi ^= deopt_context->ObjectAt(object_table_index_ + 1); 141 deopt_id_as_smi ^= deopt_context->ObjectAt(object_table_index_ + 1);
139 const Code& code = 142 const Code& code =
140 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); 143 Code::Handle(deopt_context->isolate(), function.unoptimized_code());
(...skipping 17 matching lines...) Expand all
158 public: 161 public:
159 explicit DeoptRetAddrBeforeInstr(intptr_t object_table_index) 162 explicit DeoptRetAddrBeforeInstr(intptr_t object_table_index)
160 : object_table_index_(object_table_index) { 163 : object_table_index_(object_table_index) {
161 ASSERT(object_table_index >= 0); 164 ASSERT(object_table_index >= 0);
162 } 165 }
163 166
164 virtual intptr_t from_index() const { return object_table_index_; } 167 virtual intptr_t from_index() const { return object_table_index_; }
165 virtual DeoptInstr::Kind kind() const { return kSetRetBeforeAddress; } 168 virtual DeoptInstr::Kind kind() const { return kSetRetBeforeAddress; }
166 169
167 virtual const char* ToCString() const { 170 virtual const char* ToCString() const {
168 intptr_t len = OS::SNPrint(NULL, 0, "ret bef oti:%d", object_table_index_); 171 const char* format = "ret bef oti:%"Pd"";
172 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_);
169 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 173 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
170 OS::SNPrint(chars, len + 1, "ret bef oti:%d", object_table_index_); 174 OS::SNPrint(chars, len + 1, format, object_table_index_);
171 return chars; 175 return chars;
172 } 176 }
173 177
174 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { 178 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
175 Function& function = Function::Handle(deopt_context->isolate()); 179 Function& function = Function::Handle(deopt_context->isolate());
176 function ^= deopt_context->ObjectAt(object_table_index_); 180 function ^= deopt_context->ObjectAt(object_table_index_);
177 Smi& deopt_id_as_smi = Smi::Handle(deopt_context->isolate()); 181 Smi& deopt_id_as_smi = Smi::Handle(deopt_context->isolate());
178 deopt_id_as_smi ^= deopt_context->ObjectAt(object_table_index_ + 1); 182 deopt_id_as_smi ^= deopt_context->ObjectAt(object_table_index_ + 1);
179 const Code& code = 183 const Code& code =
180 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); 184 Code::Handle(deopt_context->isolate(), function.unoptimized_code());
(...skipping 15 matching lines...) Expand all
196 public: 200 public:
197 explicit DeoptConstantInstr(intptr_t object_table_index) 201 explicit DeoptConstantInstr(intptr_t object_table_index)
198 : object_table_index_(object_table_index) { 202 : object_table_index_(object_table_index) {
199 ASSERT(object_table_index >= 0); 203 ASSERT(object_table_index >= 0);
200 } 204 }
201 205
202 virtual intptr_t from_index() const { return object_table_index_; } 206 virtual intptr_t from_index() const { return object_table_index_; }
203 virtual DeoptInstr::Kind kind() const { return kCopyConstant; } 207 virtual DeoptInstr::Kind kind() const { return kCopyConstant; }
204 208
205 virtual const char* ToCString() const { 209 virtual const char* ToCString() const {
206 intptr_t len = OS::SNPrint(NULL, 0, "const oti:%d", object_table_index_); 210 const char* format = "const oti:%"Pd"";
211 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_);
207 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 212 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
208 OS::SNPrint(chars, len + 1, "const oti:%d", object_table_index_); 213 OS::SNPrint(chars, len + 1, format, object_table_index_);
209 return chars; 214 return chars;
210 } 215 }
211 216
212 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { 217 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
213 const Object& obj = Object::Handle( 218 const Object& obj = Object::Handle(
214 deopt_context->isolate(), deopt_context->ObjectAt(object_table_index_)); 219 deopt_context->isolate(), deopt_context->ObjectAt(object_table_index_));
215 RawObject** to_addr = reinterpret_cast<RawObject**>( 220 RawObject** to_addr = reinterpret_cast<RawObject**>(
216 deopt_context->GetToFrameAddressAt(to_index)); 221 deopt_context->GetToFrameAddressAt(to_index));
217 *to_addr = obj.raw(); 222 *to_addr = obj.raw();
218 } 223 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 public: 289 public:
285 explicit DeoptPcMarkerInstr(intptr_t object_table_index) 290 explicit DeoptPcMarkerInstr(intptr_t object_table_index)
286 : object_table_index_(object_table_index) { 291 : object_table_index_(object_table_index) {
287 ASSERT(object_table_index >= 0); 292 ASSERT(object_table_index >= 0);
288 } 293 }
289 294
290 virtual intptr_t from_index() const { return object_table_index_; } 295 virtual intptr_t from_index() const { return object_table_index_; }
291 virtual DeoptInstr::Kind kind() const { return kSetPcMarker; } 296 virtual DeoptInstr::Kind kind() const { return kSetPcMarker; }
292 297
293 virtual const char* ToCString() const { 298 virtual const char* ToCString() const {
294 intptr_t len = OS::SNPrint(NULL, 0, "pcmark oti:%d", object_table_index_); 299 const char* format = "pcmark oti:%"Pd"";
300 intptr_t len = OS::SNPrint(NULL, 0, format, object_table_index_);
295 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); 301 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
296 OS::SNPrint(chars, len + 1, "pcmark oti:%d", object_table_index_); 302 OS::SNPrint(chars, len + 1, format, object_table_index_);
297 return chars; 303 return chars;
298 } 304 }
299 305
300 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { 306 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
301 Function& function = Function::Handle(deopt_context->isolate()); 307 Function& function = Function::Handle(deopt_context->isolate());
302 function ^= deopt_context->ObjectAt(object_table_index_); 308 function ^= deopt_context->ObjectAt(object_table_index_);
303 const Code& code = 309 const Code& code =
304 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); 310 Code::Handle(deopt_context->isolate(), function.unoptimized_code());
305 intptr_t pc_marker = code.EntryPoint() + 311 intptr_t pc_marker = code.EntryPoint() +
306 AssemblerMacros::kOffsetOfSavedPCfromEntrypoint; 312 AssemblerMacros::kOffsetOfSavedPCfromEntrypoint;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 const intptr_t len = instructions_.length(); 478 const intptr_t len = instructions_.length();
473 const DeoptInfo& deopt_info = DeoptInfo::Handle(DeoptInfo::New(len)); 479 const DeoptInfo& deopt_info = DeoptInfo::Handle(DeoptInfo::New(len));
474 for (intptr_t i = 0; i < len; i++) { 480 for (intptr_t i = 0; i < len; i++) {
475 DeoptInstr* instr = instructions_[i]; 481 DeoptInstr* instr = instructions_[i];
476 deopt_info.SetAt(i, instr->kind(), instr->from_index()); 482 deopt_info.SetAt(i, instr->kind(), instr->from_index());
477 } 483 }
478 return deopt_info.raw(); 484 return deopt_info.raw();
479 } 485 }
480 486
481 } // namespace dart 487 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger_api_impl_test.cc ('k') | runtime/vm/disassembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698