| 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" |
| 11 #include "vm/flow_graph_compiler.h" | 11 #include "vm/flow_graph_compiler.h" |
| 12 #include "vm/locations.h" | 12 #include "vm/locations.h" |
| 13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 14 #include "vm/parser.h" | 14 #include "vm/parser.h" |
| 15 #include "vm/stub_code.h" | 15 #include "vm/stub_code.h" |
| 16 | 16 |
| 17 #define __ compiler->assembler()-> | 17 #define __ compiler->assembler()-> |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 DECLARE_FLAG(int, optimization_counter_threshold); | 21 DECLARE_FLAG(int, optimization_counter_threshold); |
| 22 DECLARE_FLAG(bool, trace_functions); | 22 DECLARE_FLAG(bool, trace_functions); |
| 23 | 23 |
| 24 | |
| 25 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 24 void BindInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 26 computation()->EmitNativeCode(compiler); | 25 computation()->EmitNativeCode(compiler); |
| 27 __ pushq(locs()->out().reg()); | 26 __ pushq(locs()->out().reg()); |
| 28 } | 27 } |
| 29 | 28 |
| 30 | 29 |
| 31 LocationSummary* ReturnInstr::MakeLocationSummary() const { | 30 LocationSummary* ReturnInstr::MakeLocationSummary() const { |
| 32 const intptr_t kNumInputs = 1; | 31 const intptr_t kNumInputs = 1; |
| 33 const intptr_t kNumTemps = 1; | 32 const intptr_t kNumTemps = 1; |
| 34 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); | 33 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 try_index(), | 301 try_index(), |
| 303 function_name, | 302 function_name, |
| 304 kNumArguments, | 303 kNumArguments, |
| 305 Array::ZoneHandle(), // No optional arguments. | 304 Array::ZoneHandle(), // No optional arguments. |
| 306 kNumArgsChecked); | 305 kNumArgsChecked); |
| 307 } | 306 } |
| 308 | 307 |
| 309 | 308 |
| 310 LocationSummary* InstanceSetterComp::MakeLocationSummary() const { | 309 LocationSummary* InstanceSetterComp::MakeLocationSummary() const { |
| 311 const intptr_t kNumInputs = 2; | 310 const intptr_t kNumInputs = 2; |
| 312 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); | 311 return LocationSummary::Make(kNumInputs, Location::NoLocation()); |
| 313 return NULL; | 312 return NULL; |
| 314 } | 313 } |
| 315 | 314 |
| 316 | 315 |
| 317 void InstanceSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 316 void InstanceSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 318 Register receiver = locs()->in(0).reg(); | 317 Register receiver = locs()->in(0).reg(); |
| 319 Register value = locs()->in(1).reg(); | 318 Register value = locs()->in(1).reg(); |
| 320 Register result = locs()->out().reg(); | |
| 321 | 319 |
| 322 // Preserve the value (second argument) under the arguments as the result | 320 // Preserve the value (second argument) under the arguments as the result |
| 323 // of the computation, then call the setter. | 321 // of the computation, then call the setter. |
| 324 const String& function_name = | 322 const String& function_name = |
| 325 String::ZoneHandle(Field::SetterSymbol(field_name())); | 323 String::ZoneHandle(Field::SetterSymbol(field_name())); |
| 326 | 324 |
| 327 // Insert a copy of the second (last) argument under the arguments. | |
| 328 // TODO(fschneider): Avoid preserving the value if the result is not used. | |
| 329 __ pushq(value); | |
| 330 __ pushq(receiver); | 325 __ pushq(receiver); |
| 331 __ pushq(value); | 326 __ pushq(value); |
| 332 const intptr_t kArgumentCount = 2; | 327 const intptr_t kArgumentCount = 2; |
| 333 const intptr_t kCheckedArgumentCount = 1; | 328 const intptr_t kCheckedArgumentCount = 1; |
| 334 compiler->GenerateInstanceCall(cid(), | 329 compiler->GenerateInstanceCall(cid(), |
| 335 token_index(), | 330 token_index(), |
| 336 try_index(), | 331 try_index(), |
| 337 function_name, | 332 function_name, |
| 338 kArgumentCount, | 333 kArgumentCount, |
| 339 Array::ZoneHandle(), | 334 Array::ZoneHandle(), |
| 340 kCheckedArgumentCount); | 335 kCheckedArgumentCount); |
| 341 __ popq(result); | |
| 342 } | 336 } |
| 343 | 337 |
| 344 | 338 |
| 345 LocationSummary* StaticSetterComp::MakeLocationSummary() const { | 339 LocationSummary* StaticSetterComp::MakeLocationSummary() const { |
| 346 const intptr_t kNumInputs = 1; | 340 const intptr_t kNumInputs = 1; |
| 347 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); | 341 return LocationSummary::Make(kNumInputs, Location::RequiresRegister()); |
| 348 } | 342 } |
| 349 | 343 |
| 350 | 344 |
| 351 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 345 void StaticSetterComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 375 // is not used after the result is defined. We should consider adding | 369 // is not used after the result is defined. We should consider adding |
| 376 // this information to the input policy. | 370 // this information to the input policy. |
| 377 return LocationSummary::Make(1, Location::RequiresRegister()); | 371 return LocationSummary::Make(1, Location::RequiresRegister()); |
| 378 } | 372 } |
| 379 | 373 |
| 380 | 374 |
| 381 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 375 void LoadInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 382 Register instance = locs()->in(0).reg(); | 376 Register instance = locs()->in(0).reg(); |
| 383 Register result = locs()->out().reg(); | 377 Register result = locs()->out().reg(); |
| 384 | 378 |
| 379 if (class_ids() != NULL) { |
| 380 ASSERT(original() != NULL); |
| 381 Label* deopt = compiler->AddDeoptStub(original()->cid(), |
| 382 original()->token_index(), |
| 383 original()->try_index(), |
| 384 kDeoptInstanceGetterSameTarget, |
| 385 instance, |
| 386 kNoRegister); |
| 387 // Smis do not have instance fields (Smi class is always first). |
| 388 // Use 'result' as temporary register. |
| 389 ASSERT(result != instance); |
| 390 compiler->EmitClassChecksNoSmi(*class_ids(), instance, result, deopt); |
| 391 } |
| 385 __ movq(result, FieldAddress(instance, field().Offset())); | 392 __ movq(result, FieldAddress(instance, field().Offset())); |
| 386 } | 393 } |
| 387 | 394 |
| 388 | 395 |
| 389 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { | 396 LocationSummary* LoadStaticFieldComp::MakeLocationSummary() const { |
| 390 return LocationSummary::Make(0, Location::RequiresRegister()); | 397 return LocationSummary::Make(0, Location::RequiresRegister()); |
| 391 } | 398 } |
| 392 | 399 |
| 393 | 400 |
| 394 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 401 void LoadStaticFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 } else { | 1070 } else { |
| 1064 UNREACHABLE(); | 1071 UNREACHABLE(); |
| 1065 } | 1072 } |
| 1066 } | 1073 } |
| 1067 | 1074 |
| 1068 } // namespace dart | 1075 } // namespace dart |
| 1069 | 1076 |
| 1070 #undef __ | 1077 #undef __ |
| 1071 | 1078 |
| 1072 #endif // defined TARGET_ARCH_X64 | 1079 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |