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

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

Issue 10968059: Support for unboxed 64-bit integer bitwise operations and equality on ia32. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed boxing of smis and added one more test 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
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 *from_addr, reinterpret_cast<RawDouble**>(to_addr)); 115 *from_addr, reinterpret_cast<RawDouble**>(to_addr));
116 } 116 }
117 117
118 private: 118 private:
119 const intptr_t stack_slot_index_; // First argument is 0, always >= 0. 119 const intptr_t stack_slot_index_; // First argument is 0, always >= 0.
120 120
121 DISALLOW_COPY_AND_ASSIGN(DeoptDoubleStackSlotInstr); 121 DISALLOW_COPY_AND_ASSIGN(DeoptDoubleStackSlotInstr);
122 }; 122 };
123 123
124 124
125 class DeoptMintStackSlotInstr : public DeoptInstr {
126 public:
127 explicit DeoptMintStackSlotInstr(intptr_t from_index)
128 : stack_slot_index_(from_index) {
129 ASSERT(stack_slot_index_ >= 0);
130 }
131
132 virtual intptr_t from_index() const { return stack_slot_index_; }
133 virtual DeoptInstr::Kind kind() const { return kCopyMintStackSlot; }
134
135 virtual const char* ToCString() const {
136 const char* format = "ms%"Pd"";
137 intptr_t len = OS::SNPrint(NULL, 0, format, stack_slot_index_);
138 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
139 OS::SNPrint(chars, len + 1, format, stack_slot_index_);
140 return chars;
141 }
142
143 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
144 intptr_t from_index =
145 deopt_context->from_frame_size() - stack_slot_index_ - 1;
146 int64_t* from_addr = reinterpret_cast<int64_t*>(
147 deopt_context->GetFromFrameAddressAt(from_index));
148 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index);
149 *reinterpret_cast<RawSmi**>(to_addr) = Smi::New(0);
150 Isolate::Current()->DeferMintMaterialization(
151 *from_addr, reinterpret_cast<RawInteger**>(to_addr));
152 }
153
154 private:
155 const intptr_t stack_slot_index_; // First argument is 0, always >= 0.
156
157 DISALLOW_COPY_AND_ASSIGN(DeoptMintStackSlotInstr);
158 };
159
160
125 // Deoptimization instruction creating return address using function and 161 // Deoptimization instruction creating return address using function and
126 // deopt-id stored at 'object_table_index'. Uses the deopt-after 162 // deopt-id stored at 'object_table_index'. Uses the deopt-after
127 // continuation point. 163 // continuation point.
128 class DeoptRetAddrAfterInstr : public DeoptInstr { 164 class DeoptRetAddrAfterInstr : public DeoptInstr {
129 public: 165 public:
130 explicit DeoptRetAddrAfterInstr(intptr_t object_table_index) 166 explicit DeoptRetAddrAfterInstr(intptr_t object_table_index)
131 : object_table_index_(object_table_index) { 167 : object_table_index_(object_table_index) {
132 ASSERT(object_table_index >= 0); 168 ASSERT(object_table_index >= 0);
133 } 169 }
134 170
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 value, reinterpret_cast<RawDouble**>(to_addr)); 321 value, reinterpret_cast<RawDouble**>(to_addr));
286 } 322 }
287 323
288 private: 324 private:
289 const XmmRegister reg_; 325 const XmmRegister reg_;
290 326
291 DISALLOW_COPY_AND_ASSIGN(DeoptXmmRegisterInstr); 327 DISALLOW_COPY_AND_ASSIGN(DeoptXmmRegisterInstr);
292 }; 328 };
293 329
294 330
331 class DeoptMintXmmRegisterInstr: public DeoptInstr {
332 public:
333 explicit DeoptMintXmmRegisterInstr(intptr_t reg_as_int)
334 : reg_(static_cast<XmmRegister>(reg_as_int)) {}
335
336 virtual intptr_t from_index() const { return static_cast<intptr_t>(reg_); }
337 virtual DeoptInstr::Kind kind() const { return kCopyMintXmmRegister; }
338
339 virtual const char* ToCString() const {
340 const char* format = "%s(m)";
341 intptr_t len =
342 OS::SNPrint(NULL, 0, format, Assembler::XmmRegisterName(reg_));
343 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1);
344 OS::SNPrint(chars, len + 1, format, Assembler::XmmRegisterName(reg_));
345 return chars;
346 }
347
348 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) {
349 int64_t value = deopt_context->MintXmmRegisterValue(reg_);
350 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index);
351 *reinterpret_cast<RawSmi**>(to_addr) = Smi::New(0);
352 Isolate::Current()->DeferMintMaterialization(
353 value, reinterpret_cast<RawInteger**>(to_addr));
354 }
355
356 private:
357 const XmmRegister reg_;
358
359 DISALLOW_COPY_AND_ASSIGN(DeoptMintXmmRegisterInstr);
360 };
361
362
295 // Deoptimization instruction creating a PC marker for the code of 363 // Deoptimization instruction creating a PC marker for the code of
296 // function at 'object_table_index'. 364 // function at 'object_table_index'.
297 class DeoptPcMarkerInstr : public DeoptInstr { 365 class DeoptPcMarkerInstr : public DeoptInstr {
298 public: 366 public:
299 explicit DeoptPcMarkerInstr(intptr_t object_table_index) 367 explicit DeoptPcMarkerInstr(intptr_t object_table_index)
300 : object_table_index_(object_table_index) { 368 : object_table_index_(object_table_index) {
301 ASSERT(object_table_index >= 0); 369 ASSERT(object_table_index >= 0);
302 } 370 }
303 371
304 virtual intptr_t from_index() const { return object_table_index_; } 372 virtual intptr_t from_index() const { return object_table_index_; }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 private: 444 private:
377 DISALLOW_COPY_AND_ASSIGN(DeoptCallerPcInstr); 445 DISALLOW_COPY_AND_ASSIGN(DeoptCallerPcInstr);
378 }; 446 };
379 447
380 448
381 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) { 449 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) {
382 Kind kind = static_cast<Kind>(kind_as_int); 450 Kind kind = static_cast<Kind>(kind_as_int);
383 switch (kind) { 451 switch (kind) {
384 case kCopyStackSlot: return new DeoptStackSlotInstr(from_index); 452 case kCopyStackSlot: return new DeoptStackSlotInstr(from_index);
385 case kCopyDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index); 453 case kCopyDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index);
454 case kCopyMintStackSlot: return new DeoptMintStackSlotInstr(from_index);
386 case kSetRetAfterAddress: return new DeoptRetAddrAfterInstr(from_index); 455 case kSetRetAfterAddress: return new DeoptRetAddrAfterInstr(from_index);
387 case kSetRetBeforeAddress: return new DeoptRetAddrBeforeInstr(from_index); 456 case kSetRetBeforeAddress: return new DeoptRetAddrBeforeInstr(from_index);
388 case kCopyConstant: return new DeoptConstantInstr(from_index); 457 case kCopyConstant: return new DeoptConstantInstr(from_index);
389 case kCopyRegister: return new DeoptRegisterInstr(from_index); 458 case kCopyRegister: return new DeoptRegisterInstr(from_index);
390 case kCopyXmmRegister: return new DeoptXmmRegisterInstr(from_index); 459 case kCopyXmmRegister: return new DeoptXmmRegisterInstr(from_index);
460 case kCopyMintXmmRegister: return new DeoptMintXmmRegisterInstr(from_index);
391 case kSetPcMarker: return new DeoptPcMarkerInstr(from_index); 461 case kSetPcMarker: return new DeoptPcMarkerInstr(from_index);
392 case kSetCallerFp: return new DeoptCallerFpInstr(); 462 case kSetCallerFp: return new DeoptCallerFpInstr();
393 case kSetCallerPc: return new DeoptCallerPcInstr(); 463 case kSetCallerPc: return new DeoptCallerPcInstr();
394 } 464 }
395 UNREACHABLE(); 465 UNREACHABLE();
396 return NULL; 466 return NULL;
397 } 467 }
398 468
399 469
400 intptr_t DeoptInfoBuilder::FindOrAddObjectInTable(const Object& obj) const { 470 intptr_t DeoptInfoBuilder::FindOrAddObjectInTable(const Object& obj) const {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 void DeoptInfoBuilder::AddCopy(const Location& from_loc, 514 void DeoptInfoBuilder::AddCopy(const Location& from_loc,
445 const Value& from_value, 515 const Value& from_value,
446 const intptr_t to_index) { 516 const intptr_t to_index) {
447 DeoptInstr* deopt_instr = NULL; 517 DeoptInstr* deopt_instr = NULL;
448 if (from_loc.IsConstant()) { 518 if (from_loc.IsConstant()) {
449 intptr_t object_table_index = FindOrAddObjectInTable(from_loc.constant()); 519 intptr_t object_table_index = FindOrAddObjectInTable(from_loc.constant());
450 deopt_instr = new DeoptConstantInstr(object_table_index); 520 deopt_instr = new DeoptConstantInstr(object_table_index);
451 } else if (from_loc.IsRegister()) { 521 } else if (from_loc.IsRegister()) {
452 deopt_instr = new DeoptRegisterInstr(from_loc.reg()); 522 deopt_instr = new DeoptRegisterInstr(from_loc.reg());
453 } else if (from_loc.IsXmmRegister()) { 523 } else if (from_loc.IsXmmRegister()) {
454 deopt_instr = new DeoptXmmRegisterInstr(from_loc.xmm_reg()); 524 if (from_loc.representation() == Location::kDouble) {
525 deopt_instr = new DeoptXmmRegisterInstr(from_loc.xmm_reg());
526 } else {
527 ASSERT(from_loc.representation() == Location::kMint);
528 deopt_instr = new DeoptMintXmmRegisterInstr(from_loc.xmm_reg());
529 }
455 } else if (from_loc.IsStackSlot()) { 530 } else if (from_loc.IsStackSlot()) {
456 intptr_t from_index = (from_loc.stack_index() < 0) ? 531 intptr_t from_index = (from_loc.stack_index() < 0) ?
457 from_loc.stack_index() + num_args_ : 532 from_loc.stack_index() + num_args_ :
458 from_loc.stack_index() + num_args_ - 533 from_loc.stack_index() + num_args_ -
459 ParsedFunction::kFirstLocalSlotIndex + 1; 534 ParsedFunction::kFirstLocalSlotIndex + 1;
460 deopt_instr = new DeoptStackSlotInstr(from_index); 535 deopt_instr = new DeoptStackSlotInstr(from_index);
461 } else if (from_loc.IsDoubleStackSlot()) { 536 } else if (from_loc.IsDoubleStackSlot()) {
462 intptr_t from_index = (from_loc.stack_index() < 0) ? 537 intptr_t from_index = (from_loc.stack_index() < 0) ?
463 from_loc.stack_index() + num_args_ : 538 from_loc.stack_index() + num_args_ :
464 from_loc.stack_index() + num_args_ - 539 from_loc.stack_index() + num_args_ -
465 ParsedFunction::kFirstLocalSlotIndex + 1; 540 ParsedFunction::kFirstLocalSlotIndex + 1;
466 deopt_instr = new DeoptDoubleStackSlotInstr(from_index); 541 if (from_loc.representation() == Location::kDouble) {
542 deopt_instr = new DeoptDoubleStackSlotInstr(from_index);
543 } else {
544 ASSERT(from_loc.representation() == Location::kMint);
545 deopt_instr = new DeoptMintStackSlotInstr(from_index);
546 }
467 } else { 547 } else {
468 UNREACHABLE(); 548 UNREACHABLE();
469 } 549 }
470 ASSERT(to_index == instructions_.length()); 550 ASSERT(to_index == instructions_.length());
471 instructions_.Add(deopt_instr); 551 instructions_.Add(deopt_instr);
472 } 552 }
473 553
474 554
475 void DeoptInfoBuilder::AddCallerFp(intptr_t to_index) { 555 void DeoptInfoBuilder::AddCallerFp(intptr_t to_index) {
476 ASSERT(to_index == instructions_.length()); 556 ASSERT(to_index == instructions_.length());
(...skipping 11 matching lines...) Expand all
488 const intptr_t len = instructions_.length(); 568 const intptr_t len = instructions_.length();
489 const DeoptInfo& deopt_info = DeoptInfo::Handle(DeoptInfo::New(len)); 569 const DeoptInfo& deopt_info = DeoptInfo::Handle(DeoptInfo::New(len));
490 for (intptr_t i = 0; i < len; i++) { 570 for (intptr_t i = 0; i < len; i++) {
491 DeoptInstr* instr = instructions_[i]; 571 DeoptInstr* instr = instructions_[i];
492 deopt_info.SetAt(i, instr->kind(), instr->from_index()); 572 deopt_info.SetAt(i, instr->kind(), instr->from_index());
493 } 573 }
494 return deopt_info.raw(); 574 return deopt_info.raw();
495 } 575 }
496 576
497 } // namespace dart 577 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698