OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/deferred_objects.h" | 5 #include "vm/deferred_objects.h" |
6 | 6 |
7 #include "vm/deopt_instructions.h" | 7 #include "vm/deopt_instructions.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 DECLARE_FLAG(bool, trace_deoptimization_verbose); | 13 DECLARE_FLAG(bool, trace_deoptimization_verbose); |
14 | 14 |
15 | 15 |
16 void DeferredDouble::Materialize() { | 16 void DeferredDouble::Materialize(DeoptContext* deopt_context) { |
17 RawDouble** double_slot = reinterpret_cast<RawDouble**>(slot()); | 17 RawDouble** double_slot = reinterpret_cast<RawDouble**>(slot()); |
18 *double_slot = Double::New(value()); | 18 *double_slot = Double::New(value()); |
19 | 19 |
20 if (FLAG_trace_deoptimization_verbose) { | 20 if (FLAG_trace_deoptimization_verbose) { |
21 OS::PrintErr("materializing double at %" Px ": %g\n", | 21 OS::PrintErr("materializing double at %" Px ": %g\n", |
22 reinterpret_cast<uword>(slot()), value()); | 22 reinterpret_cast<uword>(slot()), value()); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 | 26 |
27 void DeferredMint::Materialize() { | 27 void DeferredMint::Materialize(DeoptContext* deopt_context) { |
28 RawMint** mint_slot = reinterpret_cast<RawMint**>(slot()); | 28 RawMint** mint_slot = reinterpret_cast<RawMint**>(slot()); |
29 ASSERT(!Smi::IsValid64(value())); | 29 ASSERT(!Smi::IsValid64(value())); |
30 Mint& mint = Mint::Handle(); | 30 Mint& mint = Mint::Handle(); |
31 mint ^= Integer::New(value()); | 31 mint ^= Integer::New(value()); |
32 *mint_slot = mint.raw(); | 32 *mint_slot = mint.raw(); |
33 | 33 |
34 if (FLAG_trace_deoptimization_verbose) { | 34 if (FLAG_trace_deoptimization_verbose) { |
35 OS::PrintErr("materializing mint at %" Px ": %" Pd64 "\n", | 35 OS::PrintErr("materializing mint at %" Px ": %" Pd64 "\n", |
36 reinterpret_cast<uword>(slot()), value()); | 36 reinterpret_cast<uword>(slot()), value()); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 void DeferredFloat32x4::Materialize() { | 41 void DeferredFloat32x4::Materialize(DeoptContext* deopt_context) { |
42 RawFloat32x4** float32x4_slot = reinterpret_cast<RawFloat32x4**>(slot()); | 42 RawFloat32x4** float32x4_slot = reinterpret_cast<RawFloat32x4**>(slot()); |
43 RawFloat32x4* raw_float32x4 = Float32x4::New(value()); | 43 RawFloat32x4* raw_float32x4 = Float32x4::New(value()); |
44 *float32x4_slot = raw_float32x4; | 44 *float32x4_slot = raw_float32x4; |
45 | 45 |
46 if (FLAG_trace_deoptimization_verbose) { | 46 if (FLAG_trace_deoptimization_verbose) { |
47 float x = raw_float32x4->x(); | 47 float x = raw_float32x4->x(); |
48 float y = raw_float32x4->y(); | 48 float y = raw_float32x4->y(); |
49 float z = raw_float32x4->z(); | 49 float z = raw_float32x4->z(); |
50 float w = raw_float32x4->w(); | 50 float w = raw_float32x4->w(); |
51 OS::PrintErr("materializing Float32x4 at %" Px ": %g,%g,%g,%g\n", | 51 OS::PrintErr("materializing Float32x4 at %" Px ": %g,%g,%g,%g\n", |
52 reinterpret_cast<uword>(slot()), x, y, z, w); | 52 reinterpret_cast<uword>(slot()), x, y, z, w); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 void DeferredInt32x4::Materialize() { | 57 void DeferredInt32x4::Materialize(DeoptContext* deopt_context) { |
58 RawInt32x4** int32x4_slot = reinterpret_cast<RawInt32x4**>(slot()); | 58 RawInt32x4** int32x4_slot = reinterpret_cast<RawInt32x4**>(slot()); |
59 RawInt32x4* raw_int32x4 = Int32x4::New(value()); | 59 RawInt32x4* raw_int32x4 = Int32x4::New(value()); |
60 *int32x4_slot = raw_int32x4; | 60 *int32x4_slot = raw_int32x4; |
61 | 61 |
62 if (FLAG_trace_deoptimization_verbose) { | 62 if (FLAG_trace_deoptimization_verbose) { |
63 uint32_t x = raw_int32x4->x(); | 63 uint32_t x = raw_int32x4->x(); |
64 uint32_t y = raw_int32x4->y(); | 64 uint32_t y = raw_int32x4->y(); |
65 uint32_t z = raw_int32x4->z(); | 65 uint32_t z = raw_int32x4->z(); |
66 uint32_t w = raw_int32x4->w(); | 66 uint32_t w = raw_int32x4->w(); |
67 OS::PrintErr("materializing Int32x4 at %" Px ": %x,%x,%x,%x\n", | 67 OS::PrintErr("materializing Int32x4 at %" Px ": %x,%x,%x,%x\n", |
68 reinterpret_cast<uword>(slot()), x, y, z, w); | 68 reinterpret_cast<uword>(slot()), x, y, z, w); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 void DeferredObjectRef::Materialize() { | 73 void DeferredObjectRef::Materialize(DeoptContext* deopt_context) { |
74 // TODO(turnidge): Consider passing the deopt_context to materialize | 74 DeferredObject* obj = deopt_context->GetDeferredObject(index()); |
75 // instead of accessing it through the current isolate. It would | |
76 // make it easier to test deferred object materialization in a unit | |
77 // test eventually. | |
78 DeferredObject* obj = | |
79 Isolate::Current()->deopt_context()->GetDeferredObject(index()); | |
80 *slot() = obj->object(); | 75 *slot() = obj->object(); |
81 if (FLAG_trace_deoptimization_verbose) { | 76 if (FLAG_trace_deoptimization_verbose) { |
82 OS::PrintErr("writing instance ref at %" Px ": %s\n", | 77 OS::PrintErr("writing instance ref at %" Px ": %s\n", |
83 reinterpret_cast<uword>(slot()), | 78 reinterpret_cast<uword>(slot()), |
84 Instance::Handle(obj->object()).ToCString()); | 79 Instance::Handle(obj->object()).ToCString()); |
85 } | 80 } |
86 } | 81 } |
87 | 82 |
88 | 83 |
89 RawInstance* DeferredObject::object() { | 84 RawInstance* DeferredObject::object() { |
(...skipping 28 matching lines...) Expand all Loading... |
118 OS::PrintErr(" %s <- %s\n", | 113 OS::PrintErr(" %s <- %s\n", |
119 String::Handle(field.name()).ToCString(), | 114 String::Handle(field.name()).ToCString(), |
120 value.ToCString()); | 115 value.ToCString()); |
121 } | 116 } |
122 } | 117 } |
123 | 118 |
124 object_ = &obj; | 119 object_ = &obj; |
125 } | 120 } |
126 | 121 |
127 } // namespace dart | 122 } // namespace dart |
OLD | NEW |