Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10389041: Adapt compile time constants and integrate with Kevin's CL 10302007 (Remove temporaries using expli… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 void FlowGraphCompiler::LoadValue(Register dst, Value* value) { 358 void FlowGraphCompiler::LoadValue(Register dst, Value* value) {
359 if (value->IsConstant()) { 359 if (value->IsConstant()) {
360 ConstantVal* constant = value->AsConstant(); 360 ConstantVal* constant = value->AsConstant();
361 if (constant->value().IsSmi()) { 361 if (constant->value().IsSmi()) {
362 int64_t imm = reinterpret_cast<int64_t>(constant->value().raw()); 362 int64_t imm = reinterpret_cast<int64_t>(constant->value().raw());
363 __ movq(dst, Immediate(imm)); 363 __ movq(dst, Immediate(imm));
364 } else { 364 } else {
365 __ LoadObject(dst, value->AsConstant()->value()); 365 __ LoadObject(dst, value->AsConstant()->value());
366 } 366 }
367 } else { 367 } else {
368 ASSERT(value->IsTemp() || value->IsUse()); 368 ASSERT(value->IsUse());
369 __ popq(dst); 369 __ popq(dst);
370 } 370 }
371 } 371 }
372 372
373 373
374 void FlowGraphCompiler::VisitTemp(TempVal* val) {
375 LoadValue(RAX, val);
376 }
377
378
379 void FlowGraphCompiler::VisitUse(UseVal* val) { 374 void FlowGraphCompiler::VisitUse(UseVal* val) {
380 LoadValue(RAX, val); 375 LoadValue(RAX, val);
381 } 376 }
382 377
383 378
384 void FlowGraphCompiler::VisitConstant(ConstantVal* val) { 379 void FlowGraphCompiler::VisitConstant(ConstantVal* val) {
385 LoadValue(RAX, val); 380 LoadValue(RAX, val);
386 } 381 }
387 382
388 383
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 419
425 // True iff. the arguments to a call will be properly pushed and can 420 // True iff. the arguments to a call will be properly pushed and can
426 // be popped after the call. 421 // be popped after the call.
427 template <typename T> static bool VerifyCallComputation(T* comp) { 422 template <typename T> static bool VerifyCallComputation(T* comp) {
428 // Argument values should be consecutive temps. 423 // Argument values should be consecutive temps.
429 // 424 //
430 // TODO(kmillikin): implement stack height tracking so we can also assert 425 // TODO(kmillikin): implement stack height tracking so we can also assert
431 // they are on top of the stack. 426 // they are on top of the stack.
432 intptr_t previous = -1; 427 intptr_t previous = -1;
433 for (int i = 0; i < comp->ArgumentCount(); ++i) { 428 for (int i = 0; i < comp->ArgumentCount(); ++i) {
434 TempVal* temp = comp->ArgumentAt(i)->AsTemp(); 429 Value* val = comp->ArgumentAt(i);
435 UseVal* use = comp->ArgumentAt(i)->AsUse(); 430 if (!val->IsUse()) return false;
436 if ((temp == NULL) && (use == NULL)) return false; 431 intptr_t current = val->AsUse()->definition()->temp_index();
437 intptr_t current =
438 (temp != NULL) ? temp->index() : use->definition()->temp_index();
439 if (i != 0) { 432 if (i != 0) {
440 if (current != (previous + 1)) return false; 433 if (current != (previous + 1)) return false;
441 } 434 }
442 previous = current; 435 previous = current;
443 } 436 }
444 return true; 437 return true;
445 } 438 }
446 439
447 440
448 // Truee iff. the v2 is above v1 on stack, or one of them is constant. 441 // Truee iff. the v2 is above v1 on stack, or one of them is constant.
449 static bool VerifyValues(Value* v1, Value* v2) { 442 static bool VerifyValues(Value* v1, Value* v2) {
450 if (v1->IsTemp() && v2->IsTemp()) { 443 if (v1->IsUse() && v2->IsUse()) {
451 return (v1->AsTemp()->index() + 1) == v2->AsTemp()->index(); 444 return (v1->AsUse()->definition()->temp_index() + 1) ==
445 v2->AsUse()->definition()->temp_index();
452 } 446 }
453 return true; 447 return true;
454 } 448 }
455 449
456 450
457 void FlowGraphCompiler::EmitInstanceCall(intptr_t cid, 451 void FlowGraphCompiler::EmitInstanceCall(intptr_t cid,
458 intptr_t token_index, 452 intptr_t token_index,
459 intptr_t try_index, 453 intptr_t try_index,
460 const String& function_name, 454 const String& function_name,
461 intptr_t argument_count, 455 intptr_t argument_count,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 __ movq(RAX, CTX); 505 __ movq(RAX, CTX);
512 } 506 }
513 507
514 508
515 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) { 509 void FlowGraphCompiler::VisitStoreContext(StoreContextComp* comp) {
516 LoadValue(CTX, comp->value()); 510 LoadValue(CTX, comp->value());
517 } 511 }
518 512
519 513
520 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { 514 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) {
521 ASSERT(comp->context()->IsTemp() || comp->context()->IsUse()); 515 ASSERT(comp->context()->IsUse());
522 ASSERT(VerifyCallComputation(comp)); 516 ASSERT(VerifyCallComputation(comp));
523 // The arguments to the stub include the closure. The arguments 517 // The arguments to the stub include the closure. The arguments
524 // descriptor describes the closure's arguments (and so does not include 518 // descriptor describes the closure's arguments (and so does not include
525 // the closure). 519 // the closure).
526 int argument_count = comp->ArgumentCount(); 520 int argument_count = comp->ArgumentCount();
527 const Array& arguments_descriptor = 521 const Array& arguments_descriptor =
528 CodeGenerator::ArgumentsDescriptor(argument_count - 1, 522 CodeGenerator::ArgumentsDescriptor(argument_count - 1,
529 comp->argument_names()); 523 comp->argument_names());
530 __ LoadObject(R10, arguments_descriptor); 524 __ LoadObject(R10, arguments_descriptor);
531 525
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 __ movq(R10, Immediate(Smi::RawValue(comp->ElementCount()))); 913 __ movq(R10, Immediate(Smi::RawValue(comp->ElementCount())));
920 LoadValue(RBX, comp->element_type()); 914 LoadValue(RBX, comp->element_type());
921 GenerateCall(comp->token_index(), 915 GenerateCall(comp->token_index(),
922 comp->try_index(), 916 comp->try_index(),
923 &StubCode::AllocateArrayLabel(), 917 &StubCode::AllocateArrayLabel(),
924 PcDescriptors::kOther); 918 PcDescriptors::kOther);
925 919
926 // 2. Initialize the array in RAX with the element values. 920 // 2. Initialize the array in RAX with the element values.
927 __ leaq(RCX, FieldAddress(RAX, Array::data_offset())); 921 __ leaq(RCX, FieldAddress(RAX, Array::data_offset()));
928 for (int i = comp->ElementCount() - 1; i >= 0; --i) { 922 for (int i = comp->ElementCount() - 1; i >= 0; --i) {
929 if (comp->ElementAt(i)->IsTemp()) { 923 if (comp->ElementAt(i)->IsUse()) {
930 __ popq(Address(RCX, i * kWordSize)); 924 __ popq(Address(RCX, i * kWordSize));
931 } else { 925 } else {
932 LoadValue(RDX, comp->ElementAt(i)); 926 LoadValue(RDX, comp->ElementAt(i));
933 __ movq(Address(RCX, i * kWordSize), RDX); 927 __ movq(Address(RCX, i * kWordSize), RDX);
934 } 928 }
935 } 929 }
936 } 930 }
937 931
938 932
939 void FlowGraphCompiler::VisitCreateClosure(CreateClosureComp* comp) { 933 void FlowGraphCompiler::VisitCreateClosure(CreateClosureComp* comp) {
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 ASSERT(exception_handlers_list_ != NULL); 1733 ASSERT(exception_handlers_list_ != NULL);
1740 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( 1734 const ExceptionHandlers& handlers = ExceptionHandlers::Handle(
1741 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); 1735 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint()));
1742 code.set_exception_handlers(handlers); 1736 code.set_exception_handlers(handlers);
1743 } 1737 }
1744 1738
1745 1739
1746 } // namespace dart 1740 } // namespace dart
1747 1741
1748 #endif // defined TARGET_ARCH_X64 1742 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698