OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
11 #include "vm/flow_graph.h" | 11 #include "vm/flow_graph.h" |
12 #include "vm/flow_graph_compiler.h" | 12 #include "vm/flow_graph_compiler.h" |
13 #include "vm/flow_graph_range_analysis.h" | 13 #include "vm/flow_graph_range_analysis.h" |
14 #include "vm/locations.h" | 14 #include "vm/locations.h" |
15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
16 #include "vm/parser.h" | 16 #include "vm/parser.h" |
17 #include "vm/stack_frame.h" | 17 #include "vm/stack_frame.h" |
18 #include "vm/stub_code.h" | 18 #include "vm/stub_code.h" |
19 #include "vm/symbols.h" | 19 #include "vm/symbols.h" |
20 | 20 |
21 #define __ compiler->assembler()-> | 21 #define __ compiler->assembler()-> |
22 | 22 |
23 namespace dart { | 23 namespace dart { |
24 | 24 |
| 25 DECLARE_FLAG(bool, allow_absolute_addresses); |
25 DECLARE_FLAG(bool, emit_edge_counters); | 26 DECLARE_FLAG(bool, emit_edge_counters); |
26 DECLARE_FLAG(int, optimization_counter_threshold); | 27 DECLARE_FLAG(int, optimization_counter_threshold); |
27 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); | 28 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); |
28 DECLARE_FLAG(bool, use_osr); | 29 DECLARE_FLAG(bool, use_osr); |
29 | 30 |
30 // Generic summary for call instructions that have all arguments pushed | 31 // Generic summary for call instructions that have all arguments pushed |
31 // on the stack and return the result in a fixed register RAX. | 32 // on the stack and return the result in a fixed register RAX. |
32 LocationSummary* Instruction::MakeCallSummary(Zone* zone) { | 33 LocationSummary* Instruction::MakeCallSummary(Zone* zone) { |
33 LocationSummary* result = new(zone) LocationSummary( | 34 LocationSummary* result = new(zone) LocationSummary( |
34 zone, 0, 0, LocationSummary::kCall); | 35 zone, 0, 0, LocationSummary::kCall); |
(...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2593 public: | 2594 public: |
2594 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction) | 2595 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction) |
2595 : instruction_(instruction) { } | 2596 : instruction_(instruction) { } |
2596 | 2597 |
2597 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 2598 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
2598 if (FLAG_use_osr && osr_entry_label()->IsLinked()) { | 2599 if (FLAG_use_osr && osr_entry_label()->IsLinked()) { |
2599 uword flags_address = Isolate::Current()->stack_overflow_flags_address(); | 2600 uword flags_address = Isolate::Current()->stack_overflow_flags_address(); |
2600 Register temp = instruction_->locs()->temp(0).reg(); | 2601 Register temp = instruction_->locs()->temp(0).reg(); |
2601 __ Comment("CheckStackOverflowSlowPathOsr"); | 2602 __ Comment("CheckStackOverflowSlowPathOsr"); |
2602 __ Bind(osr_entry_label()); | 2603 __ Bind(osr_entry_label()); |
| 2604 ASSERT(FLAG_allow_absolute_addresses); |
2603 __ LoadImmediate(temp, Immediate(flags_address)); | 2605 __ LoadImmediate(temp, Immediate(flags_address)); |
2604 __ movq(Address(temp, 0), Immediate(Isolate::kOsrRequest)); | 2606 __ movq(Address(temp, 0), Immediate(Isolate::kOsrRequest)); |
2605 } | 2607 } |
2606 __ Comment("CheckStackOverflowSlowPath"); | 2608 __ Comment("CheckStackOverflowSlowPath"); |
2607 __ Bind(entry_label()); | 2609 __ Bind(entry_label()); |
2608 compiler->SaveLiveRegisters(instruction_->locs()); | 2610 compiler->SaveLiveRegisters(instruction_->locs()); |
2609 // pending_deoptimization_env_ is needed to generate a runtime call that | 2611 // pending_deoptimization_env_ is needed to generate a runtime call that |
2610 // may throw an exception. | 2612 // may throw an exception. |
2611 ASSERT(compiler->pending_deoptimization_env_ == NULL); | 2613 ASSERT(compiler->pending_deoptimization_env_ == NULL); |
2612 Environment* env = compiler->SlowPathEnvironmentFor(instruction_); | 2614 Environment* env = compiler->SlowPathEnvironmentFor(instruction_); |
(...skipping 26 matching lines...) Expand all Loading... |
2639 Label osr_entry_label_; | 2641 Label osr_entry_label_; |
2640 }; | 2642 }; |
2641 | 2643 |
2642 | 2644 |
2643 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2645 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2644 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); | 2646 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); |
2645 compiler->AddSlowPathCode(slow_path); | 2647 compiler->AddSlowPathCode(slow_path); |
2646 | 2648 |
2647 Register temp = locs()->temp(0).reg(); | 2649 Register temp = locs()->temp(0).reg(); |
2648 // Generate stack overflow check. | 2650 // Generate stack overflow check. |
2649 if (compiler->is_optimizing()) { | 2651 if (compiler->is_optimizing() && FLAG_allow_absolute_addresses) { |
2650 __ LoadImmediate( | 2652 __ LoadImmediate( |
2651 temp, Immediate(Isolate::Current()->stack_limit_address())); | 2653 temp, Immediate(Isolate::Current()->stack_limit_address())); |
2652 __ cmpq(RSP, Address(temp, 0)); | 2654 __ cmpq(RSP, Address(temp, 0)); |
2653 } else { | 2655 } else { |
2654 __ LoadIsolate(temp); | 2656 __ LoadIsolate(temp); |
2655 __ cmpq(RSP, Address(temp, Isolate::stack_limit_offset())); | 2657 __ cmpq(RSP, Address(temp, Isolate::stack_limit_offset())); |
2656 } | 2658 } |
2657 __ j(BELOW_EQUAL, slow_path->entry_label()); | 2659 __ j(BELOW_EQUAL, slow_path->entry_label()); |
2658 if (compiler->CanOSRFunction() && in_loop()) { | 2660 if (compiler->CanOSRFunction() && in_loop()) { |
2659 // In unoptimized code check the usage counter to trigger OSR at loop | 2661 // In unoptimized code check the usage counter to trigger OSR at loop |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3398 } else if (CanConvertSmi() && (value_cid == kSmiCid)) { | 3400 } else if (CanConvertSmi() && (value_cid == kSmiCid)) { |
3399 EmitSmiConversion(compiler); | 3401 EmitSmiConversion(compiler); |
3400 } else { | 3402 } else { |
3401 const Register box = locs()->in(0).reg(); | 3403 const Register box = locs()->in(0).reg(); |
3402 Label* deopt = compiler->AddDeoptStub(GetDeoptId(), | 3404 Label* deopt = compiler->AddDeoptStub(GetDeoptId(), |
3403 ICData::kDeoptCheckClass); | 3405 ICData::kDeoptCheckClass); |
3404 Label is_smi; | 3406 Label is_smi; |
3405 | 3407 |
3406 if ((value()->Type()->ToNullableCid() == box_cid) && | 3408 if ((value()->Type()->ToNullableCid() == box_cid) && |
3407 value()->Type()->is_nullable()) { | 3409 value()->Type()->is_nullable()) { |
3408 const Immediate& raw_null = | 3410 __ CompareObject(box, Object::null_object()); |
3409 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
3410 __ cmpq(box, raw_null); | |
3411 __ j(EQUAL, deopt); | 3411 __ j(EQUAL, deopt); |
3412 } else { | 3412 } else { |
3413 __ testq(box, Immediate(kSmiTagMask)); | 3413 __ testq(box, Immediate(kSmiTagMask)); |
3414 __ j(ZERO, CanConvertSmi() ? &is_smi : deopt); | 3414 __ j(ZERO, CanConvertSmi() ? &is_smi : deopt); |
3415 __ CompareClassId(box, box_cid); | 3415 __ CompareClassId(box, box_cid); |
3416 __ j(NOT_EQUAL, deopt); | 3416 __ j(NOT_EQUAL, deopt); |
3417 } | 3417 } |
3418 | 3418 |
3419 EmitLoadFromBox(compiler); | 3419 EmitLoadFromBox(compiler); |
3420 | 3420 |
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6441 __ Drop(1); | 6441 __ Drop(1); |
6442 __ popq(result); | 6442 __ popq(result); |
6443 } | 6443 } |
6444 | 6444 |
6445 | 6445 |
6446 } // namespace dart | 6446 } // namespace dart |
6447 | 6447 |
6448 #undef __ | 6448 #undef __ |
6449 | 6449 |
6450 #endif // defined TARGET_ARCH_X64 | 6450 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |