| 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" |
| 11 #include "vm/ast_printer.h" | 11 #include "vm/ast_printer.h" |
| 12 #include "vm/il_printer.h" | 12 #include "vm/il_printer.h" |
| 13 #include "vm/locations.h" | 13 #include "vm/locations.h" |
| 14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/parser.h" | 15 #include "vm/parser.h" |
| 16 #include "vm/stub_code.h" | 16 #include "vm/stub_code.h" |
| 17 #include "vm/symbols.h" | 17 #include "vm/symbols.h" |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 DECLARE_FLAG(bool, enable_type_checks); | 21 DECLARE_FLAG(bool, enable_type_checks); |
| 22 DECLARE_FLAG(bool, print_ast); | 22 DECLARE_FLAG(bool, print_ast); |
| 23 DECLARE_FLAG(bool, print_scopes); | 23 DECLARE_FLAG(bool, print_scopes); |
| 24 DECLARE_FLAG(bool, trace_functions); | 24 DECLARE_FLAG(bool, trace_functions); |
| 25 | 25 |
| 26 | 26 |
| 27 void DeoptimizationStub::GenerateCode(FlowGraphCompiler* compiler, | 27 void CompilerDeoptInfoWithStub::GenerateCode(FlowGraphCompiler* compiler, |
| 28 intptr_t stub_ix) { | 28 intptr_t stub_ix) { |
| 29 // Calls do not need stubs, they share a deoptimization trampoline. | 29 // Calls do not need stubs, they share a deoptimization trampoline. |
| 30 if (reason_ == kDeoptAtCall) return; | 30 ASSERT(reason() != kDeoptAtCall); |
| 31 Assembler* assem = compiler->assembler(); | 31 Assembler* assem = compiler->assembler(); |
| 32 #define __ assem-> | 32 #define __ assem-> |
| 33 __ Comment("Deopt stub for id %d", deopt_id_); | 33 __ Comment("Deopt stub for id %d", deopt_id()); |
| 34 __ Bind(entry_label()); | 34 __ Bind(entry_label()); |
| 35 | 35 |
| 36 ASSERT(deoptimization_env_ != NULL); | 36 ASSERT(deoptimization_env() != NULL); |
| 37 | 37 |
| 38 if (compiler->IsLeaf()) { | 38 if (compiler->IsLeaf()) { |
| 39 __ Comment("Leaf method, lazy PC marker setup"); | 39 __ Comment("Leaf method, lazy PC marker setup"); |
| 40 // TODO(srdjan): Can we use TMP instead of RAX? We must guarantee that | 40 // TODO(srdjan): Can we use TMP instead of RAX? We must guarantee that |
| 41 // TMP is never part of deoptimization environment. | 41 // TMP is never part of deoptimization environment. |
| 42 __ pushq(RAX); // Preserve RAX. | 42 __ pushq(RAX); // Preserve RAX. |
| 43 Label L; | 43 Label L; |
| 44 __ call(&L); | 44 __ call(&L); |
| 45 const intptr_t offset = assem->CodeSize(); | 45 const intptr_t offset = assem->CodeSize(); |
| 46 __ Bind(&L); | 46 __ Bind(&L); |
| 47 __ popq(RAX); | 47 __ popq(RAX); |
| 48 __ subq(RAX, | 48 __ subq(RAX, |
| 49 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); | 49 Immediate(offset - AssemblerMacros::kOffsetOfSavedPCfromEntrypoint)); |
| 50 __ movq(Address(RBP, -kWordSize), RAX); | 50 __ movq(Address(RBP, -kWordSize), RAX); |
| 51 __ popq(RAX); // Restore RAX. | 51 __ popq(RAX); // Restore RAX. |
| 52 } | 52 } |
| 53 __ call(&StubCode::DeoptimizeLabel()); | 53 __ call(&StubCode::DeoptimizeLabel()); |
| 54 const intptr_t deopt_info_index = stub_ix; | 54 const intptr_t deopt_info_index = stub_ix; |
| 55 compiler->pc_descriptors_list()->AddDeoptIndex( | 55 compiler->pc_descriptors_list()->AddDeoptIndex( |
| 56 compiler->assembler()->CodeSize(), | 56 compiler->assembler()->CodeSize(), |
| 57 deopt_id_, | 57 deopt_id(), |
| 58 reason_, | 58 reason(), |
| 59 deopt_info_index); | 59 deopt_info_index); |
| 60 __ int3(); | 60 __ int3(); |
| 61 #undef __ | 61 #undef __ |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 #define __ assembler()-> | 65 #define __ assembler()-> |
| 66 | 66 |
| 67 | 67 |
| 68 // Fall through if bool_register contains null. | 68 // Fall through if bool_register contains null. |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { | 1303 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { |
| 1304 __ Exchange(mem1, mem2); | 1304 __ Exchange(mem1, mem2); |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 | 1307 |
| 1308 #undef __ | 1308 #undef __ |
| 1309 | 1309 |
| 1310 } // namespace dart | 1310 } // namespace dart |
| 1311 | 1311 |
| 1312 #endif // defined TARGET_ARCH_X64 | 1312 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |