Chromium Code Reviews| 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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 void FlowGraphCompiler::LoadValue(Register dst, Value* value) { | 370 void FlowGraphCompiler::LoadValue(Register dst, Value* value) { |
| 371 if (value->IsConstant()) { | 371 if (value->IsConstant()) { |
| 372 ConstantVal* constant = value->AsConstant(); | 372 ConstantVal* constant = value->AsConstant(); |
| 373 if (constant->value().IsSmi()) { | 373 if (constant->value().IsSmi()) { |
| 374 int64_t imm = reinterpret_cast<int64_t>(constant->value().raw()); | 374 int64_t imm = reinterpret_cast<int64_t>(constant->value().raw()); |
| 375 __ movq(dst, Immediate(imm)); | 375 __ movq(dst, Immediate(imm)); |
| 376 } else { | 376 } else { |
| 377 __ LoadObject(dst, value->AsConstant()->value()); | 377 __ LoadObject(dst, value->AsConstant()->value()); |
| 378 } | 378 } |
| 379 } else { | 379 } else { |
| 380 ASSERT(value->IsTemp()); | 380 ASSERT(value->IsTemp() || value->IsUse()); |
| 381 __ popq(dst); | 381 __ popq(dst); |
| 382 } | 382 } |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 void FlowGraphCompiler::VisitTemp(TempVal* val) { | 386 void FlowGraphCompiler::VisitTemp(TempVal* val) { |
| 387 LoadValue(RAX, val); | 387 LoadValue(RAX, val); |
| 388 } | 388 } |
| 389 | 389 |
| 390 | 390 |
| 391 void FlowGraphCompiler::VisitUse(UseVal* val) { | |
| 392 LoadValue(RAX, val); | |
| 393 } | |
| 394 | |
| 395 | |
| 391 void FlowGraphCompiler::VisitConstant(ConstantVal* val) { | 396 void FlowGraphCompiler::VisitConstant(ConstantVal* val) { |
| 392 LoadValue(RAX, val); | 397 LoadValue(RAX, val); |
| 393 } | 398 } |
| 394 | 399 |
| 395 | 400 |
| 396 void FlowGraphCompiler::VisitAssertAssignable(AssertAssignableComp* comp) { | 401 void FlowGraphCompiler::VisitAssertAssignable(AssertAssignableComp* comp) { |
| 397 if (comp->instantiator_type_arguments() != NULL) { | 402 if (comp->instantiator_type_arguments() != NULL) { |
| 398 __ popq(RDX); | 403 __ popq(RDX); |
| 399 } | 404 } |
| 400 LoadValue(RAX, comp->value()); | 405 LoadValue(RAX, comp->value()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 // True iff. the arguments to a call will be properly pushed and can | 439 // True iff. the arguments to a call will be properly pushed and can |
| 435 // be popped after the call. | 440 // be popped after the call. |
| 436 template <typename T> static bool VerifyCallComputation(T* comp) { | 441 template <typename T> static bool VerifyCallComputation(T* comp) { |
| 437 // Argument values should be consecutive temps. | 442 // Argument values should be consecutive temps. |
| 438 // | 443 // |
| 439 // TODO(kmillikin): implement stack height tracking so we can also assert | 444 // TODO(kmillikin): implement stack height tracking so we can also assert |
| 440 // they are on top of the stack. | 445 // they are on top of the stack. |
| 441 intptr_t previous = -1; | 446 intptr_t previous = -1; |
| 442 for (int i = 0; i < comp->ArgumentCount(); ++i) { | 447 for (int i = 0; i < comp->ArgumentCount(); ++i) { |
| 443 TempVal* temp = comp->ArgumentAt(i)->AsTemp(); | 448 TempVal* temp = comp->ArgumentAt(i)->AsTemp(); |
| 444 if (temp == NULL) return false; | 449 UseVal* use = comp->ArgumentAt(i)->AsUse(); |
| 450 if (temp == NULL && use == NULL) return false; | |
|
srdjan
2012/04/24 22:02:18
Use parenthesis
Kevin Millikin (Google)
2012/04/25 08:50:51
Done. Thanks for the reminder.
| |
| 451 intptr_t current = | |
| 452 (temp != NULL) ? temp->index() : use->definition()->temp_index(); | |
| 445 if (i != 0) { | 453 if (i != 0) { |
| 446 if (temp->index() != previous + 1) return false; | 454 if (current != previous + 1) return false; |
|
srdjan
2012/04/24 22:02:18
ditto
Kevin Millikin (Google)
2012/04/25 08:50:51
Done.
| |
| 447 } | 455 } |
| 448 previous = temp->index(); | 456 previous = current; |
| 449 } | 457 } |
| 450 return true; | 458 return true; |
| 451 } | 459 } |
| 452 | 460 |
| 453 | 461 |
| 454 // Truee iff. the v2 is above v1 on stack, or one of them is constant. | 462 // Truee iff. the v2 is above v1 on stack, or one of them is constant. |
| 455 static bool VerifyValues(Value* v1, Value* v2) { | 463 static bool VerifyValues(Value* v1, Value* v2) { |
| 456 if (v1->IsTemp() && v2->IsTemp()) { | 464 if (v1->IsTemp() && v2->IsTemp()) { |
| 457 return (v1->AsTemp()->index() + 1) == v2->AsTemp()->index(); | 465 return (v1->AsTemp()->index() + 1) == v2->AsTemp()->index(); |
| 458 } | 466 } |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 assembler_->CodeSize()); | 1188 assembler_->CodeSize()); |
| 1181 } | 1189 } |
| 1182 } | 1190 } |
| 1183 | 1191 |
| 1184 | 1192 |
| 1185 void FlowGraphCompiler::VisitPickTemp(PickTempInstr* instr) { | 1193 void FlowGraphCompiler::VisitPickTemp(PickTempInstr* instr) { |
| 1186 // Semantics is to copy a stack-allocated temporary to the top of stack. | 1194 // Semantics is to copy a stack-allocated temporary to the top of stack. |
| 1187 // Destination index d is assumed the new top of stack after the | 1195 // Destination index d is assumed the new top of stack after the |
| 1188 // operation, so d-1 is the current top of stack and so d-s-1 is the | 1196 // operation, so d-1 is the current top of stack and so d-s-1 is the |
| 1189 // offset to source index s. | 1197 // offset to source index s. |
| 1190 intptr_t offset = instr->destination() - instr->source() - 1; | 1198 intptr_t offset = instr->temp_index() - instr->source() - 1; |
| 1191 ASSERT(offset >= 0); | 1199 ASSERT(offset >= 0); |
| 1192 __ pushq(Address(RSP, offset * kWordSize)); | 1200 __ pushq(Address(RSP, offset * kWordSize)); |
| 1193 } | 1201 } |
| 1194 | 1202 |
| 1195 | 1203 |
| 1196 void FlowGraphCompiler::VisitTuckTemp(TuckTempInstr* instr) { | 1204 void FlowGraphCompiler::VisitTuckTemp(TuckTempInstr* instr) { |
| 1197 // Semantics is to assign to a stack-allocated temporary a copy of the top | 1205 // Semantics is to assign to a stack-allocated temporary a copy of the top |
| 1198 // of stack. Source index s is assumed the top of stack, s-d is the | 1206 // of stack. Source index s is assumed the top of stack, s-d is the |
| 1199 // offset to destination index d. | 1207 // offset to destination index d. |
| 1200 intptr_t offset = instr->source() - instr->destination(); | 1208 intptr_t offset = instr->source() - instr->destination(); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1714 ASSERT(exception_handlers_list_ != NULL); | 1722 ASSERT(exception_handlers_list_ != NULL); |
| 1715 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( | 1723 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( |
| 1716 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); | 1724 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); |
| 1717 code.set_exception_handlers(handlers); | 1725 code.set_exception_handlers(handlers); |
| 1718 } | 1726 } |
| 1719 | 1727 |
| 1720 | 1728 |
| 1721 } // namespace dart | 1729 } // namespace dart |
| 1722 | 1730 |
| 1723 #endif // defined TARGET_ARCH_X64 | 1731 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |