| OLD | NEW |
| 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/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/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 __ Bind(¬_yet_hot); | 78 __ Bind(¬_yet_hot); |
| 79 __ Bind(&already_optimized); | 79 __ Bind(&already_optimized); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 if (FLAG_trace_functions) { | 82 if (FLAG_trace_functions) { |
| 83 const Function& function = | 83 const Function& function = |
| 84 Function::ZoneHandle(compiler->parsed_function().function().raw()); | 84 Function::ZoneHandle(compiler->parsed_function().function().raw()); |
| 85 __ LoadObject(temp, function); | 85 __ LoadObject(temp, function); |
| 86 __ pushq(result); // Preserve result. | 86 __ pushq(result); // Preserve result. |
| 87 __ pushq(temp); | 87 __ pushq(temp); |
| 88 compiler->GenerateCallRuntime(Isolate::kNoDeoptId, | 88 compiler->GenerateCallRuntime(0, |
| 89 0, | |
| 90 kTraceFunctionExitRuntimeEntry, | 89 kTraceFunctionExitRuntimeEntry, |
| 91 NULL); | 90 NULL); |
| 92 __ popq(temp); // Remove argument. | 91 __ popq(temp); // Remove argument. |
| 93 __ popq(result); // Restore result. | 92 __ popq(result); // Restore result. |
| 94 } | 93 } |
| 95 #if defined(DEBUG) | 94 #if defined(DEBUG) |
| 96 // TODO(srdjan): Fix for functions with finally clause. | 95 // TODO(srdjan): Fix for functions with finally clause. |
| 97 // A finally clause may leave a previously pushed return value if it | 96 // A finally clause may leave a previously pushed return value if it |
| 98 // has its own return instruction. Method that have finally are currently | 97 // has its own return instruction. Method that have finally are currently |
| 99 // not optimized. | 98 // not optimized. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 if (!is_eliminated()) { | 210 if (!is_eliminated()) { |
| 212 // Check that the type of the value is allowed in conditional context. | 211 // Check that the type of the value is allowed in conditional context. |
| 213 // Call the runtime if the object is not bool::true or bool::false. | 212 // Call the runtime if the object is not bool::true or bool::false. |
| 214 Label done; | 213 Label done; |
| 215 __ CompareObject(obj, compiler->bool_true()); | 214 __ CompareObject(obj, compiler->bool_true()); |
| 216 __ j(EQUAL, &done, Assembler::kNearJump); | 215 __ j(EQUAL, &done, Assembler::kNearJump); |
| 217 __ CompareObject(obj, compiler->bool_false()); | 216 __ CompareObject(obj, compiler->bool_false()); |
| 218 __ j(EQUAL, &done, Assembler::kNearJump); | 217 __ j(EQUAL, &done, Assembler::kNearJump); |
| 219 | 218 |
| 220 __ pushq(obj); // Push the source object. | 219 __ pushq(obj); // Push the source object. |
| 221 compiler->GenerateCallRuntime(deopt_id(), | 220 compiler->GenerateCallRuntime(token_pos(), |
| 222 token_pos(), | |
| 223 kConditionTypeErrorRuntimeEntry, | 221 kConditionTypeErrorRuntimeEntry, |
| 224 locs()); | 222 locs()); |
| 225 // We should never return here. | 223 // We should never return here. |
| 226 __ int3(); | 224 __ int3(); |
| 227 __ Bind(&done); | 225 __ Bind(&done); |
| 228 } | 226 } |
| 229 ASSERT(obj == result); | 227 ASSERT(obj == result); |
| 230 } | 228 } |
| 231 | 229 |
| 232 | 230 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 243 | 241 |
| 244 void ArgumentDefinitionTestComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 242 void ArgumentDefinitionTestComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 245 Register saved_args_desc = locs()->in(0).reg(); | 243 Register saved_args_desc = locs()->in(0).reg(); |
| 246 Register result = locs()->out().reg(); | 244 Register result = locs()->out().reg(); |
| 247 | 245 |
| 248 // Push the result place holder initialized to NULL. | 246 // Push the result place holder initialized to NULL. |
| 249 __ PushObject(Object::ZoneHandle()); | 247 __ PushObject(Object::ZoneHandle()); |
| 250 __ pushq(Immediate(Smi::RawValue(formal_parameter_index()))); | 248 __ pushq(Immediate(Smi::RawValue(formal_parameter_index()))); |
| 251 __ PushObject(formal_parameter_name()); | 249 __ PushObject(formal_parameter_name()); |
| 252 __ pushq(saved_args_desc); | 250 __ pushq(saved_args_desc); |
| 253 compiler->GenerateCallRuntime(deopt_id(), | 251 compiler->GenerateCallRuntime(token_pos(), |
| 254 token_pos(), | |
| 255 kArgumentDefinitionTestRuntimeEntry, | 252 kArgumentDefinitionTestRuntimeEntry, |
| 256 locs()); | 253 locs()); |
| 257 __ Drop(3); | 254 __ Drop(3); |
| 258 __ popq(result); // Pop bool result. | 255 __ popq(result); // Pop bool result. |
| 259 } | 256 } |
| 260 | 257 |
| 261 | 258 |
| 262 static Condition TokenKindToSmiCondition(Token::Kind kind) { | 259 static Condition TokenKindToSmiCondition(Token::Kind kind) { |
| 263 switch (kind) { | 260 switch (kind) { |
| 264 case Token::kEQ: return EQUAL; | 261 case Token::kEQ: return EQUAL; |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 summary->set_out(Location::RegisterLocation(RAX)); | 1068 summary->set_out(Location::RegisterLocation(RAX)); |
| 1072 return summary; | 1069 return summary; |
| 1073 } | 1070 } |
| 1074 | 1071 |
| 1075 | 1072 |
| 1076 void InstanceOfComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1073 void InstanceOfComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1077 ASSERT(locs()->in(0).reg() == RAX); // Value. | 1074 ASSERT(locs()->in(0).reg() == RAX); // Value. |
| 1078 ASSERT(locs()->in(1).reg() == RCX); // Instantiator. | 1075 ASSERT(locs()->in(1).reg() == RCX); // Instantiator. |
| 1079 ASSERT(locs()->in(2).reg() == RDX); // Instantiator type arguments. | 1076 ASSERT(locs()->in(2).reg() == RDX); // Instantiator type arguments. |
| 1080 | 1077 |
| 1081 compiler->GenerateInstanceOf(deopt_id(), | 1078 compiler->GenerateInstanceOf(token_pos(), |
| 1082 token_pos(), | |
| 1083 type(), | 1079 type(), |
| 1084 negate_result(), | 1080 negate_result(), |
| 1085 locs()); | 1081 locs()); |
| 1086 ASSERT(locs()->out().reg() == RAX); | 1082 ASSERT(locs()->out().reg() == RAX); |
| 1087 } | 1083 } |
| 1088 | 1084 |
| 1089 | 1085 |
| 1090 LocationSummary* CreateArrayComp::MakeLocationSummary() const { | 1086 LocationSummary* CreateArrayComp::MakeLocationSummary() const { |
| 1091 const intptr_t kNumInputs = 1; | 1087 const intptr_t kNumInputs = 1; |
| 1092 const intptr_t kNumTemps = 0; | 1088 const intptr_t kNumTemps = 0; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 const Class& cls = Class::ZoneHandle(constructor().Owner()); | 1130 const Class& cls = Class::ZoneHandle(constructor().Owner()); |
| 1135 Register type_arguments = locs()->in(0).reg(); | 1131 Register type_arguments = locs()->in(0).reg(); |
| 1136 Register instantiator_type_arguments = locs()->in(1).reg(); | 1132 Register instantiator_type_arguments = locs()->in(1).reg(); |
| 1137 Register result = locs()->out().reg(); | 1133 Register result = locs()->out().reg(); |
| 1138 | 1134 |
| 1139 // Push the result place holder initialized to NULL. | 1135 // Push the result place holder initialized to NULL. |
| 1140 __ PushObject(Object::ZoneHandle()); | 1136 __ PushObject(Object::ZoneHandle()); |
| 1141 __ PushObject(cls); | 1137 __ PushObject(cls); |
| 1142 __ pushq(type_arguments); | 1138 __ pushq(type_arguments); |
| 1143 __ pushq(instantiator_type_arguments); | 1139 __ pushq(instantiator_type_arguments); |
| 1144 compiler->GenerateCallRuntime(deopt_id(), | 1140 compiler->GenerateCallRuntime(token_pos(), |
| 1145 token_pos(), | |
| 1146 kAllocateObjectWithBoundsCheckRuntimeEntry, | 1141 kAllocateObjectWithBoundsCheckRuntimeEntry, |
| 1147 locs()); | 1142 locs()); |
| 1148 // Pop instantiator type arguments, type arguments, and class. | 1143 // Pop instantiator type arguments, type arguments, and class. |
| 1149 __ Drop(3); | 1144 __ Drop(3); |
| 1150 __ popq(result); // Pop new instance. | 1145 __ popq(result); // Pop new instance. |
| 1151 } | 1146 } |
| 1152 | 1147 |
| 1153 | 1148 |
| 1154 LocationSummary* LoadVMFieldComp::MakeLocationSummary() const { | 1149 LocationSummary* LoadVMFieldComp::MakeLocationSummary() const { |
| 1155 return LocationSummary::Make(1, | 1150 return LocationSummary::Make(1, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); | 1202 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); |
| 1208 __ cmpq(FieldAddress(instantiator_reg, TypeArguments::length_offset()), | 1203 __ cmpq(FieldAddress(instantiator_reg, TypeArguments::length_offset()), |
| 1209 Immediate(Smi::RawValue(len))); | 1204 Immediate(Smi::RawValue(len))); |
| 1210 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | 1205 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 1211 __ Bind(&type_arguments_uninstantiated); | 1206 __ Bind(&type_arguments_uninstantiated); |
| 1212 } | 1207 } |
| 1213 // A runtime call to instantiate the type arguments is required. | 1208 // A runtime call to instantiate the type arguments is required. |
| 1214 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 1209 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 1215 __ PushObject(type_arguments()); | 1210 __ PushObject(type_arguments()); |
| 1216 __ pushq(instantiator_reg); // Push instantiator type arguments. | 1211 __ pushq(instantiator_reg); // Push instantiator type arguments. |
| 1217 compiler->GenerateCallRuntime(deopt_id(), | 1212 compiler->GenerateCallRuntime(token_pos(), |
| 1218 token_pos(), | |
| 1219 kInstantiateTypeArgumentsRuntimeEntry, | 1213 kInstantiateTypeArgumentsRuntimeEntry, |
| 1220 locs()); | 1214 locs()); |
| 1221 __ Drop(2); // Drop instantiator and uninstantiated type arguments. | 1215 __ Drop(2); // Drop instantiator and uninstantiated type arguments. |
| 1222 __ popq(result_reg); // Pop instantiated type arguments. | 1216 __ popq(result_reg); // Pop instantiated type arguments. |
| 1223 __ Bind(&type_arguments_instantiated); | 1217 __ Bind(&type_arguments_instantiated); |
| 1224 ASSERT(instantiator_reg == result_reg); | 1218 ASSERT(instantiator_reg == result_reg); |
| 1225 // 'result_reg': Instantiated type arguments. | 1219 // 'result_reg': Instantiated type arguments. |
| 1226 } | 1220 } |
| 1227 | 1221 |
| 1228 | 1222 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 return locs; | 1376 return locs; |
| 1383 } | 1377 } |
| 1384 | 1378 |
| 1385 | 1379 |
| 1386 void CloneContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1380 void CloneContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1387 Register context_value = locs()->in(0).reg(); | 1381 Register context_value = locs()->in(0).reg(); |
| 1388 Register result = locs()->out().reg(); | 1382 Register result = locs()->out().reg(); |
| 1389 | 1383 |
| 1390 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 1384 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 1391 __ pushq(context_value); | 1385 __ pushq(context_value); |
| 1392 compiler->GenerateCallRuntime(deopt_id(), | 1386 compiler->GenerateCallRuntime(token_pos(), |
| 1393 token_pos(), | |
| 1394 kCloneContextRuntimeEntry, | 1387 kCloneContextRuntimeEntry, |
| 1395 locs()); | 1388 locs()); |
| 1396 __ popq(result); // Remove argument. | 1389 __ popq(result); // Remove argument. |
| 1397 __ popq(result); // Get result (cloned context). | 1390 __ popq(result); // Get result (cloned context). |
| 1398 } | 1391 } |
| 1399 | 1392 |
| 1400 | 1393 |
| 1401 LocationSummary* CatchEntryComp::MakeLocationSummary() const { | 1394 LocationSummary* CatchEntryComp::MakeLocationSummary() const { |
| 1402 return LocationSummary::Make(0, | 1395 return LocationSummary::Make(0, |
| 1403 Location::NoLocation(), | 1396 Location::NoLocation(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 | 1431 |
| 1439 | 1432 |
| 1440 class CheckStackOverflowSlowPath : public SlowPathCode { | 1433 class CheckStackOverflowSlowPath : public SlowPathCode { |
| 1441 public: | 1434 public: |
| 1442 explicit CheckStackOverflowSlowPath(CheckStackOverflowComp* computation) | 1435 explicit CheckStackOverflowSlowPath(CheckStackOverflowComp* computation) |
| 1443 : computation_(computation) { } | 1436 : computation_(computation) { } |
| 1444 | 1437 |
| 1445 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 1438 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1446 __ Bind(entry_label()); | 1439 __ Bind(entry_label()); |
| 1447 compiler->SaveLiveRegisters(computation_->locs()); | 1440 compiler->SaveLiveRegisters(computation_->locs()); |
| 1448 compiler->GenerateCallRuntime(computation_->deopt_id(), | 1441 compiler->GenerateCallRuntime(computation_->token_pos(), |
| 1449 computation_->token_pos(), | |
| 1450 kStackOverflowRuntimeEntry, | 1442 kStackOverflowRuntimeEntry, |
| 1451 computation_->locs()); | 1443 computation_->locs()); |
| 1452 compiler->RestoreLiveRegisters(computation_->locs()); | 1444 compiler->RestoreLiveRegisters(computation_->locs()); |
| 1453 __ jmp(exit_label()); | 1445 __ jmp(exit_label()); |
| 1454 } | 1446 } |
| 1455 | 1447 |
| 1456 private: | 1448 private: |
| 1457 CheckStackOverflowComp* computation_; | 1449 CheckStackOverflowComp* computation_; |
| 1458 }; | 1450 }; |
| 1459 | 1451 |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 } | 2248 } |
| 2257 __ j(ABOVE_EQUAL, deopt); | 2249 __ j(ABOVE_EQUAL, deopt); |
| 2258 } | 2250 } |
| 2259 | 2251 |
| 2260 | 2252 |
| 2261 } // namespace dart | 2253 } // namespace dart |
| 2262 | 2254 |
| 2263 #undef __ | 2255 #undef __ |
| 2264 | 2256 |
| 2265 #endif // defined TARGET_ARCH_X64 | 2257 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |