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/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
11 #include "vm/heap_trace.h" | 11 #include "vm/heap_trace.h" |
12 #include "vm/memory_region.h" | 12 #include "vm/memory_region.h" |
13 #include "vm/runtime_entry.h" | 13 #include "vm/runtime_entry.h" |
14 #include "vm/stub_code.h" | 14 #include "vm/stub_code.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
18 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); | 18 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); |
19 DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available"); | 19 DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available"); |
| 20 DECLARE_FLAG(bool, inline_alloc); |
20 | 21 |
21 | 22 |
22 bool CPUFeatures::sse2_supported_ = false; | 23 bool CPUFeatures::sse2_supported_ = false; |
23 bool CPUFeatures::sse4_1_supported_ = false; | 24 bool CPUFeatures::sse4_1_supported_ = false; |
24 #ifdef DEBUG | 25 #ifdef DEBUG |
25 bool CPUFeatures::initialized_ = false; | 26 bool CPUFeatures::initialized_ = false; |
26 #endif | 27 #endif |
27 | 28 |
28 | 29 |
29 bool CPUFeatures::sse2_supported() { | 30 bool CPUFeatures::sse2_supported() { |
(...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 while (label->HasNear()) { | 2108 while (label->HasNear()) { |
2108 int position = label->NearPosition(); | 2109 int position = label->NearPosition(); |
2109 int offset = bound - (position + 1); | 2110 int offset = bound - (position + 1); |
2110 ASSERT(Utils::IsInt(8, offset)); | 2111 ASSERT(Utils::IsInt(8, offset)); |
2111 buffer_.Store<int8_t>(position, offset); | 2112 buffer_.Store<int8_t>(position, offset); |
2112 } | 2113 } |
2113 label->BindTo(bound); | 2114 label->BindTo(bound); |
2114 } | 2115 } |
2115 | 2116 |
2116 | 2117 |
| 2118 void Assembler::TryAllocate(const Class& cls, |
| 2119 Label* failure, |
| 2120 bool near_jump, |
| 2121 Register instance_reg) { |
| 2122 ASSERT(failure != NULL); |
| 2123 if (FLAG_inline_alloc) { |
| 2124 Heap* heap = Isolate::Current()->heap(); |
| 2125 const intptr_t instance_size = cls.instance_size(); |
| 2126 movl(instance_reg, Address::Absolute(heap->TopAddress())); |
| 2127 addl(instance_reg, Immediate(instance_size)); |
| 2128 // instance_reg: potential next object start. |
| 2129 cmpl(instance_reg, Address::Absolute(heap->EndAddress())); |
| 2130 j(ABOVE_EQUAL, failure, near_jump); |
| 2131 // Successfully allocated the object, now update top to point to |
| 2132 // next object start and store the class in the class field of object. |
| 2133 movl(Address::Absolute(heap->TopAddress()), instance_reg); |
| 2134 ASSERT(instance_size >= kHeapObjectTag); |
| 2135 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
| 2136 uword tags = 0; |
| 2137 tags = RawObject::SizeTag::update(instance_size, tags); |
| 2138 ASSERT(cls.id() != kIllegalCid); |
| 2139 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 2140 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); |
| 2141 } else { |
| 2142 jmp(failure); |
| 2143 } |
| 2144 } |
| 2145 |
| 2146 |
| 2147 void Assembler::EnterDartFrame(intptr_t frame_size) { |
| 2148 const intptr_t offset = CodeSize(); |
| 2149 EnterFrame(0); |
| 2150 Label dart_entry; |
| 2151 call(&dart_entry); |
| 2152 Bind(&dart_entry); |
| 2153 // Adjust saved PC for any intrinsic code that could have been generated |
| 2154 // before a frame is created. |
| 2155 if (offset != 0) { |
| 2156 addl(Address(ESP, 0), Immediate(-offset)); |
| 2157 } |
| 2158 if (frame_size != 0) { |
| 2159 subl(ESP, Immediate(frame_size)); |
| 2160 } |
| 2161 } |
| 2162 |
| 2163 |
| 2164 void Assembler::EnterStubFrame() { |
| 2165 EnterFrame(0); |
| 2166 pushl(Immediate(0)); // Push 0 in the saved PC area for stub frames. |
| 2167 } |
| 2168 |
| 2169 |
2117 void Assembler::Stop(const char* message) { | 2170 void Assembler::Stop(const char* message) { |
2118 if (FLAG_print_stop_message) { | 2171 if (FLAG_print_stop_message) { |
2119 pushl(EAX); // Preserve EAX. | 2172 pushl(EAX); // Preserve EAX. |
2120 movl(EAX, Immediate(reinterpret_cast<int32_t>(message))); | 2173 movl(EAX, Immediate(reinterpret_cast<int32_t>(message))); |
2121 call(&StubCode::PrintStopMessageLabel()); // Passing message in EAX. | 2174 call(&StubCode::PrintStopMessageLabel()); // Passing message in EAX. |
2122 popl(EAX); // Restore EAX. | 2175 popl(EAX); // Restore EAX. |
2123 } else { | 2176 } else { |
2124 // Emit the message address as immediate operand in the test instruction. | 2177 // Emit the message address as immediate operand in the test instruction. |
2125 testl(EAX, Immediate(reinterpret_cast<int32_t>(message))); | 2178 testl(EAX, Immediate(reinterpret_cast<int32_t>(message))); |
2126 } | 2179 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 | 2334 |
2282 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2335 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
2283 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2336 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
2284 return xmm_reg_names[reg]; | 2337 return xmm_reg_names[reg]; |
2285 } | 2338 } |
2286 | 2339 |
2287 | 2340 |
2288 } // namespace dart | 2341 } // namespace dart |
2289 | 2342 |
2290 #endif // defined TARGET_ARCH_IA32 | 2343 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |