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

Unified Diff: runtime/vm/deopt_instructions.cc

Issue 345563007: Add Uint32 representation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/deopt_instructions.cc
diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc
index 2f365fbfd20494098f9d20d2088066bbd1077840..da39c9ff7c5917f7430d0a92c9594e69e3dd2507 100644
--- a/runtime/vm/deopt_instructions.cc
+++ b/runtime/vm/deopt_instructions.cc
@@ -890,6 +890,77 @@ class DeoptMintStackSlotRegisterInstr : public DeoptInstr {
};
+class DeoptMint32StackSlotInstr : public DeoptInstr {
+ public:
+ explicit DeoptMint32StackSlotInstr(intptr_t source_index)
+ : stack_slot_index_(source_index) {
+ ASSERT(stack_slot_index_ >= 0);
+ }
+
+ virtual intptr_t source_index() const { return stack_slot_index_; }
+ virtual DeoptInstr::Kind kind() const { return kMint32StackSlot; }
+
+ virtual const char* ToCString() const {
+ return Isolate::Current()->current_zone()->PrintToString(
+ "(32-bit) int64 s%" Pd "", stack_slot_index_);
+ }
+
+ void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) {
+ intptr_t source_index =
+ deopt_context->source_frame_size() - stack_slot_index_ - 1;
+ intptr_t* source_addr =
+ deopt_context->GetSourceFrameAddressAt(source_index);
+ int64_t value = Utils::LowHighTo64Bits(*source_addr, 0);
+ *reinterpret_cast<RawSmi**>(dest_addr) = Smi::New(0);
+ if (Smi::IsValid(value)) {
+ *dest_addr = reinterpret_cast<intptr_t>(
+ Smi::New(static_cast<intptr_t>(value)));
+ } else {
+ deopt_context->DeferMintMaterialization(
+ value, reinterpret_cast<RawMint**>(dest_addr));
+ }
+ }
+
+ private:
+ const intptr_t stack_slot_index_; // First argument is 0, always >= 0.
+
+ DISALLOW_COPY_AND_ASSIGN(DeoptMint32StackSlotInstr);
+};
+
+
+class DeoptMint32RegisterInstr: public DeoptInstr {
+ public:
+ explicit DeoptMint32RegisterInstr(intptr_t reg_as_int)
+ : reg_(static_cast<Register>(reg_as_int)) {}
+
+ virtual intptr_t source_index() const { return static_cast<intptr_t>(reg_); }
+ virtual DeoptInstr::Kind kind() const { return kMint32Register; }
+
+ virtual const char* ToCString() const {
+ return Isolate::Current()->current_zone()->PrintToString(
+ "(32-bit) int64 register %s", Assembler::RegisterName(reg_));
+ }
+
+ void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) {
+ int32_t lo = deopt_context->RegisterValue(reg_);
+ int64_t value = Utils::LowHighTo64Bits(lo, 0);
+ *reinterpret_cast<RawSmi**>(dest_addr) = Smi::New(0);
+ if (Smi::IsValid(value)) {
+ *dest_addr = reinterpret_cast<intptr_t>(
+ Smi::New(static_cast<intptr_t>(value)));
+ } else {
+ deopt_context->DeferMintMaterialization(
+ value, reinterpret_cast<RawMint**>(dest_addr));
+ }
+ }
+
+ private:
+ const Register reg_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeoptMint32RegisterInstr);
+};
+
+
// Deoptimization instruction moving an XMM register.
class DeoptFloat32x4FpuRegisterInstr: public DeoptInstr {
public:
@@ -1299,6 +1370,12 @@ DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t source_index) {
bool flip = DeoptMintStackSlotRegisterInstr::Flip::decode(source_index);
return new DeoptMintStackSlotRegisterInstr(slot, reg_as_int, flip);
}
+ case kMint32Register: {
+ return new DeoptMint32RegisterInstr(source_index);
+ }
+ case kMint32StackSlot: {
+ return new DeoptMint32StackSlotInstr(source_index);
+ }
case kFloat32x4FpuRegister:
return new DeoptFloat32x4FpuRegisterInstr(source_index);
case kFloat64x2FpuRegister:
@@ -1427,8 +1504,12 @@ void DeoptInfoBuilder::AddCopy(Value* value,
intptr_t object_table_index = FindOrAddObjectInTable(source_loc.constant());
deopt_instr = new(isolate()) DeoptConstantInstr(object_table_index);
} else if (source_loc.IsRegister()) {
- ASSERT(value->definition()->representation() == kTagged);
- deopt_instr = new(isolate()) DeoptRegisterInstr(source_loc.reg());
+ if (value->definition()->representation() == kTagged) {
+ deopt_instr = new(isolate()) DeoptRegisterInstr(source_loc.reg());
+ } else {
+ ASSERT(value->definition()->representation() == kUnboxedMint32);
+ deopt_instr = new(isolate()) DeoptMint32RegisterInstr(source_loc.reg());
+ }
} else if (source_loc.IsFpuRegister()) {
if (value->definition()->representation() == kUnboxedDouble) {
deopt_instr = new(isolate()) DeoptFpuRegisterInstr(source_loc.fpu_reg());
@@ -1444,9 +1525,14 @@ void DeoptInfoBuilder::AddCopy(Value* value,
new(isolate()) DeoptFloat64x2FpuRegisterInstr(source_loc.fpu_reg());
}
} else if (source_loc.IsStackSlot()) {
- ASSERT(value->definition()->representation() == kTagged);
- intptr_t source_index = CalculateStackIndex(source_loc);
- deopt_instr = new(isolate()) DeoptStackSlotInstr(source_index);
+ if (value->definition()->representation() == kTagged) {
+ intptr_t source_index = CalculateStackIndex(source_loc);
+ deopt_instr = new(isolate()) DeoptStackSlotInstr(source_index);
+ } else {
+ ASSERT(value->definition()->representation() == kUnboxedMint32);
+ intptr_t source_index = CalculateStackIndex(source_loc);
+ deopt_instr = new(isolate()) DeoptMint32StackSlotInstr(source_index);
+ }
} else if (source_loc.IsDoubleStackSlot()) {
ASSERT(value->definition()->representation() == kUnboxedDouble);
intptr_t source_index = CalculateStackIndex(source_loc);

Powered by Google App Engine
This is Rietveld 408576698