| 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 "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 void FlowGraphCompiler::VisitTemp(TempVal* val) { | 62 void FlowGraphCompiler::VisitTemp(TempVal* val) { |
| 63 LoadValue(val); | 63 LoadValue(val); |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 void FlowGraphCompiler::VisitConstant(ConstantVal* val) { | 67 void FlowGraphCompiler::VisitConstant(ConstantVal* val) { |
| 68 LoadValue(val); | 68 LoadValue(val); |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 void FlowGraphCompiler::VisitCopyTemp(CopyTempComp* comp) { | |
| 73 // Index is a stack index. Semantics is to produce a duplicate of the | |
| 74 // temp at index. | |
| 75 __ movq(RAX, Address(RSP, comp->index() * (-kWordSize))); | |
| 76 } | |
| 77 | |
| 78 | |
| 79 void FlowGraphCompiler::VisitSetTemp(SetTempComp* comp) { | |
| 80 // Index is a stack index. Semantics is to store a (copy of) the TOS in | |
| 81 // the temp at index. | |
| 82 __ movq(RAX, Address(RSP, 0)); | |
| 83 __ movq(Address(RSP, comp->index() * (-kWordSize)), RAX); | |
| 84 } | |
| 85 | |
| 86 | |
| 87 void FlowGraphCompiler::VisitAssertAssignable(AssertAssignableComp* comp) { | 72 void FlowGraphCompiler::VisitAssertAssignable(AssertAssignableComp* comp) { |
| 88 Bailout("AssertAssignableComp"); | 73 Bailout("AssertAssignableComp"); |
| 89 } | 74 } |
| 90 | 75 |
| 91 | 76 |
| 92 // True iff. the arguments to a call will be properly pushed and can | 77 // True iff. the arguments to a call will be properly pushed and can |
| 93 // be popped after the call. | 78 // be popped after the call. |
| 94 template <typename T> static bool VerifyCallComputation(T* comp) { | 79 template <typename T> static bool VerifyCallComputation(T* comp) { |
| 95 // Argument values should be consecutive temps. | 80 // Argument values should be consecutive temps. |
| 96 // | 81 // |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void FlowGraphCompiler::VisitJoinEntry(JoinEntryInstr* instr) { | 263 void FlowGraphCompiler::VisitJoinEntry(JoinEntryInstr* instr) { |
| 279 Bailout("JoinEntryInstr"); | 264 Bailout("JoinEntryInstr"); |
| 280 } | 265 } |
| 281 | 266 |
| 282 | 267 |
| 283 void FlowGraphCompiler::VisitTargetEntry(TargetEntryInstr* instr) { | 268 void FlowGraphCompiler::VisitTargetEntry(TargetEntryInstr* instr) { |
| 284 // Since we don't handle branching control flow yet, there is nothing to do. | 269 // Since we don't handle branching control flow yet, there is nothing to do. |
| 285 } | 270 } |
| 286 | 271 |
| 287 | 272 |
| 273 void FlowGraphCompiler::VisitPickTemp(PickTempInstr* instr) { |
| 274 // Semantics is to copy a stack-allocated temporary to the top of stack. |
| 275 // Destination index d is assumed the new top of stack after the |
| 276 // operation, so d-1 is the current top of stack and so d-s-1 is the |
| 277 // offset to source index s. |
| 278 intptr_t offset = instr->destination() - instr->source() - 1; |
| 279 ASSERT(offset >= 0); |
| 280 __ pushq(Address(RSP, offset * kWordSize)); |
| 281 } |
| 282 |
| 283 |
| 284 void FlowGraphCompiler::VisitTuckTemp(TuckTempInstr* instr) { |
| 285 // Semantics is to assign to a stack-allocated temporary a copy of the top |
| 286 // of stack. Source index s is assumed the top of stack, s-d is the |
| 287 // offset to destination index d. |
| 288 intptr_t offset = instr->source() - instr->destination(); |
| 289 ASSERT(offset >= 0); |
| 290 __ movq(RAX, Address(RSP, 0)); |
| 291 __ movq(Address(RSP, offset * kWordSize), RAX); |
| 292 } |
| 293 |
| 294 |
| 288 void FlowGraphCompiler::VisitDo(DoInstr* instr) { | 295 void FlowGraphCompiler::VisitDo(DoInstr* instr) { |
| 289 instr->computation()->Accept(this); | 296 instr->computation()->Accept(this); |
| 290 } | 297 } |
| 291 | 298 |
| 292 | 299 |
| 293 void FlowGraphCompiler::VisitBind(BindInstr* instr) { | 300 void FlowGraphCompiler::VisitBind(BindInstr* instr) { |
| 294 instr->computation()->Accept(this); | 301 instr->computation()->Accept(this); |
| 295 __ pushq(RAX); | 302 __ pushq(RAX); |
| 296 } | 303 } |
| 297 | 304 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { | 488 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { |
| 482 // We don't compile exception handlers yet. | 489 // We don't compile exception handlers yet. |
| 483 code.set_exception_handlers( | 490 code.set_exception_handlers( |
| 484 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); | 491 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); |
| 485 } | 492 } |
| 486 | 493 |
| 487 | 494 |
| 488 } // namespace dart | 495 } // namespace dart |
| 489 | 496 |
| 490 #endif // defined TARGET_ARCH_X64 | 497 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |