| 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" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 void FlowGraphCompiler::EmitEdgeCounter() { | 1233 void FlowGraphCompiler::EmitEdgeCounter() { |
| 1234 // We do not check for overflow when incrementing the edge counter. The | 1234 // We do not check for overflow when incrementing the edge counter. The |
| 1235 // function should normally be optimized long before the counter can | 1235 // function should normally be optimized long before the counter can |
| 1236 // overflow; and though we do not reset the counters when we optimize or | 1236 // overflow; and though we do not reset the counters when we optimize or |
| 1237 // deoptimize, there is a bound on the number of | 1237 // deoptimize, there is a bound on the number of |
| 1238 // optimization/deoptimization cycles we will attempt. | 1238 // optimization/deoptimization cycles we will attempt. |
| 1239 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); | 1239 const Array& counter = Array::ZoneHandle(Array::New(1, Heap::kOld)); |
| 1240 counter.SetAt(0, Smi::Handle(Smi::New(0))); | 1240 counter.SetAt(0, Smi::Handle(Smi::New(0))); |
| 1241 __ Comment("Edge counter"); | 1241 __ Comment("Edge counter"); |
| 1242 __ LoadObject(RAX, counter, PP); | 1242 __ LoadObject(RAX, counter, PP); |
| 1243 #if defined(DEBUG) | |
| 1244 intptr_t increment_start = assembler_->CodeSize(); | 1243 intptr_t increment_start = assembler_->CodeSize(); |
| 1245 #endif // DEBUG | |
| 1246 __ IncrementSmiField(FieldAddress(RAX, Array::element_offset(0)), 1); | 1244 __ IncrementSmiField(FieldAddress(RAX, Array::element_offset(0)), 1); |
| 1247 #if defined(DEBUG) | 1245 int32_t size = assembler_->CodeSize() - increment_start; |
| 1248 // If the assertion below fails, update EdgeCounterIncrementSizeInBytes. | 1246 if (isolate()->edge_counter_increment_size() == -1) { |
| 1249 intptr_t expected = EdgeCounterIncrementSizeInBytes(); | 1247 isolate()->set_edge_counter_increment_size(size); |
| 1250 intptr_t actual = assembler_->CodeSize() - increment_start; | 1248 } else { |
| 1251 if (actual != expected) { | 1249 ASSERT(size == isolate()->edge_counter_increment_size()); |
| 1252 FATAL2("Edge counter increment length: %" Pd ", expected %" Pd "\n", | |
| 1253 actual, | |
| 1254 expected); | |
| 1255 } | 1250 } |
| 1256 #endif // DEBUG | |
| 1257 } | 1251 } |
| 1258 | 1252 |
| 1259 | 1253 |
| 1260 int32_t FlowGraphCompiler::EdgeCounterIncrementSizeInBytes() { | 1254 int32_t FlowGraphCompiler::EdgeCounterIncrementSizeInBytes() { |
| 1261 // Used by CodePatcher; so must be constant across all code in an isolate. | 1255 const int32_t size = Isolate::Current()->edge_counter_increment_size(); |
| 1262 int32_t size = 5; | 1256 ASSERT(size != -1); |
| 1263 #if defined(DEBUG) | |
| 1264 size += 36; // VerifySmi | |
| 1265 #endif // DEBUG | |
| 1266 if (VerifiedMemory::enabled()) { | |
| 1267 size += 72; | |
| 1268 } | |
| 1269 return size; | 1257 return size; |
| 1270 } | 1258 } |
| 1271 | 1259 |
| 1272 | 1260 |
| 1273 void FlowGraphCompiler::EmitOptimizedInstanceCall( | 1261 void FlowGraphCompiler::EmitOptimizedInstanceCall( |
| 1274 ExternalLabel* target_label, | 1262 ExternalLabel* target_label, |
| 1275 const ICData& ic_data, | 1263 const ICData& ic_data, |
| 1276 intptr_t argument_count, | 1264 intptr_t argument_count, |
| 1277 intptr_t deopt_id, | 1265 intptr_t deopt_id, |
| 1278 intptr_t token_pos, | 1266 intptr_t token_pos, |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 __ movups(reg, Address(RSP, 0)); | 1774 __ movups(reg, Address(RSP, 0)); |
| 1787 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1775 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
| 1788 } | 1776 } |
| 1789 | 1777 |
| 1790 | 1778 |
| 1791 #undef __ | 1779 #undef __ |
| 1792 | 1780 |
| 1793 } // namespace dart | 1781 } // namespace dart |
| 1794 | 1782 |
| 1795 #endif // defined TARGET_ARCH_X64 | 1783 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |