| 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 __ Bind(¬_yet_hot); | 77 __ Bind(¬_yet_hot); |
| 78 __ Bind(&already_optimized); | 78 __ Bind(&already_optimized); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 if (FLAG_trace_functions) { | 81 if (FLAG_trace_functions) { |
| 82 const Function& function = | 82 const Function& function = |
| 83 Function::ZoneHandle(compiler->parsed_function().function().raw()); | 83 Function::ZoneHandle(compiler->parsed_function().function().raw()); |
| 84 __ LoadObject(temp, function); | 84 __ LoadObject(temp, function); |
| 85 __ pushl(result); // Preserve result. | 85 __ pushl(result); // Preserve result. |
| 86 __ pushl(temp); | 86 __ pushl(temp); |
| 87 compiler->GenerateCallRuntime(Isolate::kNoDeoptId, | 87 compiler->GenerateCallRuntime(0, |
| 88 0, | |
| 89 kTraceFunctionExitRuntimeEntry, | 88 kTraceFunctionExitRuntimeEntry, |
| 90 locs()); | 89 locs()); |
| 91 __ popl(temp); // Remove argument. | 90 __ popl(temp); // Remove argument. |
| 92 __ popl(result); // Restore result. | 91 __ popl(result); // Restore result. |
| 93 } | 92 } |
| 94 #if defined(DEBUG) | 93 #if defined(DEBUG) |
| 95 // TODO(srdjan): Fix for functions with finally clause. | 94 // TODO(srdjan): Fix for functions with finally clause. |
| 96 // A finally clause may leave a previously pushed return value if it | 95 // A finally clause may leave a previously pushed return value if it |
| 97 // has its own return instruction. Method that have finally are currently | 96 // has its own return instruction. Method that have finally are currently |
| 98 // not optimized. | 97 // not optimized. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (!is_eliminated()) { | 201 if (!is_eliminated()) { |
| 203 // Check that the type of the value is allowed in conditional context. | 202 // Check that the type of the value is allowed in conditional context. |
| 204 // Call the runtime if the object is not bool::true or bool::false. | 203 // Call the runtime if the object is not bool::true or bool::false. |
| 205 Label done; | 204 Label done; |
| 206 __ CompareObject(obj, compiler->bool_true()); | 205 __ CompareObject(obj, compiler->bool_true()); |
| 207 __ j(EQUAL, &done, Assembler::kNearJump); | 206 __ j(EQUAL, &done, Assembler::kNearJump); |
| 208 __ CompareObject(obj, compiler->bool_false()); | 207 __ CompareObject(obj, compiler->bool_false()); |
| 209 __ j(EQUAL, &done, Assembler::kNearJump); | 208 __ j(EQUAL, &done, Assembler::kNearJump); |
| 210 | 209 |
| 211 __ pushl(obj); // Push the source object. | 210 __ pushl(obj); // Push the source object. |
| 212 compiler->GenerateCallRuntime(deopt_id(), | 211 compiler->GenerateCallRuntime(token_pos(), |
| 213 token_pos(), | |
| 214 kConditionTypeErrorRuntimeEntry, | 212 kConditionTypeErrorRuntimeEntry, |
| 215 locs()); | 213 locs()); |
| 216 // We should never return here. | 214 // We should never return here. |
| 217 __ int3(); | 215 __ int3(); |
| 218 __ Bind(&done); | 216 __ Bind(&done); |
| 219 } | 217 } |
| 220 ASSERT(obj == result); | 218 ASSERT(obj == result); |
| 221 } | 219 } |
| 222 | 220 |
| 223 | 221 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 234 | 232 |
| 235 void ArgumentDefinitionTestComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 233 void ArgumentDefinitionTestComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 236 Register saved_args_desc = locs()->in(0).reg(); | 234 Register saved_args_desc = locs()->in(0).reg(); |
| 237 Register result = locs()->out().reg(); | 235 Register result = locs()->out().reg(); |
| 238 | 236 |
| 239 // Push the result place holder initialized to NULL. | 237 // Push the result place holder initialized to NULL. |
| 240 __ PushObject(Object::ZoneHandle()); | 238 __ PushObject(Object::ZoneHandle()); |
| 241 __ pushl(Immediate(Smi::RawValue(formal_parameter_index()))); | 239 __ pushl(Immediate(Smi::RawValue(formal_parameter_index()))); |
| 242 __ PushObject(formal_parameter_name()); | 240 __ PushObject(formal_parameter_name()); |
| 243 __ pushl(saved_args_desc); | 241 __ pushl(saved_args_desc); |
| 244 compiler->GenerateCallRuntime(deopt_id(), | 242 compiler->GenerateCallRuntime(token_pos(), |
| 245 token_pos(), | |
| 246 kArgumentDefinitionTestRuntimeEntry, | 243 kArgumentDefinitionTestRuntimeEntry, |
| 247 locs()); | 244 locs()); |
| 248 __ Drop(3); | 245 __ Drop(3); |
| 249 __ popl(result); // Pop bool result. | 246 __ popl(result); // Pop bool result. |
| 250 } | 247 } |
| 251 | 248 |
| 252 | 249 |
| 253 static Condition TokenKindToSmiCondition(Token::Kind kind) { | 250 static Condition TokenKindToSmiCondition(Token::Kind kind) { |
| 254 switch (kind) { | 251 switch (kind) { |
| 255 case Token::kEQ: return EQUAL; | 252 case Token::kEQ: return EQUAL; |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 summary->set_out(Location::RegisterLocation(EAX)); | 1045 summary->set_out(Location::RegisterLocation(EAX)); |
| 1049 return summary; | 1046 return summary; |
| 1050 } | 1047 } |
| 1051 | 1048 |
| 1052 | 1049 |
| 1053 void InstanceOfComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1050 void InstanceOfComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1054 ASSERT(locs()->in(0).reg() == EAX); // Value. | 1051 ASSERT(locs()->in(0).reg() == EAX); // Value. |
| 1055 ASSERT(locs()->in(1).reg() == ECX); // Instantiator. | 1052 ASSERT(locs()->in(1).reg() == ECX); // Instantiator. |
| 1056 ASSERT(locs()->in(2).reg() == EDX); // Instantiator type arguments. | 1053 ASSERT(locs()->in(2).reg() == EDX); // Instantiator type arguments. |
| 1057 | 1054 |
| 1058 compiler->GenerateInstanceOf(deopt_id(), | 1055 compiler->GenerateInstanceOf(token_pos(), |
| 1059 token_pos(), | |
| 1060 type(), | 1056 type(), |
| 1061 negate_result(), | 1057 negate_result(), |
| 1062 locs()); | 1058 locs()); |
| 1063 ASSERT(locs()->out().reg() == EAX); | 1059 ASSERT(locs()->out().reg() == EAX); |
| 1064 } | 1060 } |
| 1065 | 1061 |
| 1066 | 1062 |
| 1067 LocationSummary* CreateArrayComp::MakeLocationSummary() const { | 1063 LocationSummary* CreateArrayComp::MakeLocationSummary() const { |
| 1068 const intptr_t kNumInputs = 1; | 1064 const intptr_t kNumInputs = 1; |
| 1069 const intptr_t kNumTemps = 0; | 1065 const intptr_t kNumTemps = 0; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 const Class& cls = Class::ZoneHandle(constructor().Owner()); | 1107 const Class& cls = Class::ZoneHandle(constructor().Owner()); |
| 1112 Register type_arguments = locs()->in(0).reg(); | 1108 Register type_arguments = locs()->in(0).reg(); |
| 1113 Register instantiator_type_arguments = locs()->in(1).reg(); | 1109 Register instantiator_type_arguments = locs()->in(1).reg(); |
| 1114 Register result = locs()->out().reg(); | 1110 Register result = locs()->out().reg(); |
| 1115 | 1111 |
| 1116 // Push the result place holder initialized to NULL. | 1112 // Push the result place holder initialized to NULL. |
| 1117 __ PushObject(Object::ZoneHandle()); | 1113 __ PushObject(Object::ZoneHandle()); |
| 1118 __ PushObject(cls); | 1114 __ PushObject(cls); |
| 1119 __ pushl(type_arguments); | 1115 __ pushl(type_arguments); |
| 1120 __ pushl(instantiator_type_arguments); | 1116 __ pushl(instantiator_type_arguments); |
| 1121 compiler->GenerateCallRuntime(deopt_id(), | 1117 compiler->GenerateCallRuntime(token_pos(), |
| 1122 token_pos(), | |
| 1123 kAllocateObjectWithBoundsCheckRuntimeEntry, | 1118 kAllocateObjectWithBoundsCheckRuntimeEntry, |
| 1124 locs()); | 1119 locs()); |
| 1125 // Pop instantiator type arguments, type arguments, and class. | 1120 // Pop instantiator type arguments, type arguments, and class. |
| 1126 // source location. | 1121 // source location. |
| 1127 __ Drop(3); | 1122 __ Drop(3); |
| 1128 __ popl(result); // Pop new instance. | 1123 __ popl(result); // Pop new instance. |
| 1129 } | 1124 } |
| 1130 | 1125 |
| 1131 | 1126 |
| 1132 LocationSummary* LoadVMFieldComp::MakeLocationSummary() const { | 1127 LocationSummary* LoadVMFieldComp::MakeLocationSummary() const { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); | 1182 __ j(NOT_EQUAL, &type_arguments_uninstantiated, Assembler::kNearJump); |
| 1188 __ cmpl(FieldAddress(instantiator_reg, TypeArguments::length_offset()), | 1183 __ cmpl(FieldAddress(instantiator_reg, TypeArguments::length_offset()), |
| 1189 Immediate(Smi::RawValue(len))); | 1184 Immediate(Smi::RawValue(len))); |
| 1190 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); | 1185 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
| 1191 __ Bind(&type_arguments_uninstantiated); | 1186 __ Bind(&type_arguments_uninstantiated); |
| 1192 } | 1187 } |
| 1193 // A runtime call to instantiate the type arguments is required. | 1188 // A runtime call to instantiate the type arguments is required. |
| 1194 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 1189 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 1195 __ PushObject(type_arguments()); | 1190 __ PushObject(type_arguments()); |
| 1196 __ pushl(instantiator_reg); // Push instantiator type arguments. | 1191 __ pushl(instantiator_reg); // Push instantiator type arguments. |
| 1197 compiler->GenerateCallRuntime(deopt_id(), | 1192 compiler->GenerateCallRuntime(token_pos(), |
| 1198 token_pos(), | |
| 1199 kInstantiateTypeArgumentsRuntimeEntry, | 1193 kInstantiateTypeArgumentsRuntimeEntry, |
| 1200 locs()); | 1194 locs()); |
| 1201 __ Drop(2); // Drop instantiator and uninstantiated type arguments. | 1195 __ Drop(2); // Drop instantiator and uninstantiated type arguments. |
| 1202 __ popl(result_reg); // Pop instantiated type arguments. | 1196 __ popl(result_reg); // Pop instantiated type arguments. |
| 1203 __ Bind(&type_arguments_instantiated); | 1197 __ Bind(&type_arguments_instantiated); |
| 1204 ASSERT(instantiator_reg == result_reg); | 1198 ASSERT(instantiator_reg == result_reg); |
| 1205 // 'result_reg': Instantiated type arguments. | 1199 // 'result_reg': Instantiated type arguments. |
| 1206 } | 1200 } |
| 1207 | 1201 |
| 1208 | 1202 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 return locs; | 1360 return locs; |
| 1367 } | 1361 } |
| 1368 | 1362 |
| 1369 | 1363 |
| 1370 void CloneContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1364 void CloneContextComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1371 Register context_value = locs()->in(0).reg(); | 1365 Register context_value = locs()->in(0).reg(); |
| 1372 Register result = locs()->out().reg(); | 1366 Register result = locs()->out().reg(); |
| 1373 | 1367 |
| 1374 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 1368 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 1375 __ pushl(context_value); | 1369 __ pushl(context_value); |
| 1376 compiler->GenerateCallRuntime(deopt_id(), | 1370 compiler->GenerateCallRuntime(token_pos(), |
| 1377 token_pos(), | |
| 1378 kCloneContextRuntimeEntry, | 1371 kCloneContextRuntimeEntry, |
| 1379 locs()); | 1372 locs()); |
| 1380 __ popl(result); // Remove argument. | 1373 __ popl(result); // Remove argument. |
| 1381 __ popl(result); // Get result (cloned context). | 1374 __ popl(result); // Get result (cloned context). |
| 1382 } | 1375 } |
| 1383 | 1376 |
| 1384 | 1377 |
| 1385 LocationSummary* CatchEntryComp::MakeLocationSummary() const { | 1378 LocationSummary* CatchEntryComp::MakeLocationSummary() const { |
| 1386 return LocationSummary::Make(0, | 1379 return LocationSummary::Make(0, |
| 1387 Location::NoLocation(), | 1380 Location::NoLocation(), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 | 1414 |
| 1422 | 1415 |
| 1423 class CheckStackOverflowSlowPath : public SlowPathCode { | 1416 class CheckStackOverflowSlowPath : public SlowPathCode { |
| 1424 public: | 1417 public: |
| 1425 explicit CheckStackOverflowSlowPath(CheckStackOverflowComp* computation) | 1418 explicit CheckStackOverflowSlowPath(CheckStackOverflowComp* computation) |
| 1426 : computation_(computation) { } | 1419 : computation_(computation) { } |
| 1427 | 1420 |
| 1428 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 1421 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1429 __ Bind(entry_label()); | 1422 __ Bind(entry_label()); |
| 1430 compiler->SaveLiveRegisters(computation_->locs()); | 1423 compiler->SaveLiveRegisters(computation_->locs()); |
| 1431 compiler->GenerateCallRuntime(computation_->deopt_id(), | 1424 compiler->GenerateCallRuntime(computation_->token_pos(), |
| 1432 computation_->token_pos(), | |
| 1433 kStackOverflowRuntimeEntry, | 1425 kStackOverflowRuntimeEntry, |
| 1434 computation_->locs()); | 1426 computation_->locs()); |
| 1435 compiler->RestoreLiveRegisters(computation_->locs()); | 1427 compiler->RestoreLiveRegisters(computation_->locs()); |
| 1436 __ jmp(exit_label()); | 1428 __ jmp(exit_label()); |
| 1437 } | 1429 } |
| 1438 | 1430 |
| 1439 private: | 1431 private: |
| 1440 CheckStackOverflowComp* computation_; | 1432 CheckStackOverflowComp* computation_; |
| 1441 }; | 1433 }; |
| 1442 | 1434 |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 } | 2234 } |
| 2243 __ j(ABOVE_EQUAL, deopt); | 2235 __ j(ABOVE_EQUAL, deopt); |
| 2244 } | 2236 } |
| 2245 | 2237 |
| 2246 | 2238 |
| 2247 } // namespace dart | 2239 } // namespace dart |
| 2248 | 2240 |
| 2249 #undef __ | 2241 #undef __ |
| 2250 | 2242 |
| 2251 #endif // defined TARGET_ARCH_X64 | 2243 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |