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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/flow_graph_allocator.h" | 10 #include "vm/flow_graph_allocator.h" |
11 #include "vm/flow_graph_builder.h" | 11 #include "vm/flow_graph_builder.h" |
12 #include "vm/flow_graph_compiler.h" | 12 #include "vm/flow_graph_compiler.h" |
13 #include "vm/flow_graph_optimizer.h" | 13 #include "vm/flow_graph_optimizer.h" |
14 #include "vm/flow_graph_range_analysis.h" | 14 #include "vm/flow_graph_range_analysis.h" |
15 #include "vm/locations.h" | 15 #include "vm/locations.h" |
16 #include "vm/method_recognizer.h" | 16 #include "vm/method_recognizer.h" |
17 #include "vm/object.h" | 17 #include "vm/object.h" |
18 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
19 #include "vm/os.h" | 19 #include "vm/os.h" |
20 #include "vm/regexp_assembler.h" | |
21 #include "vm/resolver.h" | 20 #include "vm/resolver.h" |
22 #include "vm/scopes.h" | 21 #include "vm/scopes.h" |
23 #include "vm/stub_code.h" | 22 #include "vm/stub_code.h" |
24 #include "vm/symbols.h" | 23 #include "vm/symbols.h" |
25 | 24 |
26 #include "vm/il_printer.h" | 25 #include "vm/il_printer.h" |
27 | 26 |
28 namespace dart { | 27 namespace dart { |
29 | 28 |
30 DEFINE_FLAG(bool, propagate_ic_data, true, | 29 DEFINE_FLAG(bool, propagate_ic_data, true, |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 } | 444 } |
446 | 445 |
447 | 446 |
448 GraphEntryInstr::GraphEntryInstr(const ParsedFunction* parsed_function, | 447 GraphEntryInstr::GraphEntryInstr(const ParsedFunction* parsed_function, |
449 TargetEntryInstr* normal_entry, | 448 TargetEntryInstr* normal_entry, |
450 intptr_t osr_id) | 449 intptr_t osr_id) |
451 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), | 450 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), |
452 parsed_function_(parsed_function), | 451 parsed_function_(parsed_function), |
453 normal_entry_(normal_entry), | 452 normal_entry_(normal_entry), |
454 catch_entries_(), | 453 catch_entries_(), |
455 indirect_entries_(), | |
456 initial_definitions_(), | 454 initial_definitions_(), |
457 osr_id_(osr_id), | 455 osr_id_(osr_id), |
458 entry_count_(0), | 456 entry_count_(0), |
459 spill_slot_count_(0), | 457 spill_slot_count_(0), |
460 fixed_slot_count_(0) { | 458 fixed_slot_count_(0) { |
461 } | 459 } |
462 | 460 |
463 | 461 |
464 ConstantInstr* GraphEntryInstr::constant_null() { | 462 ConstantInstr* GraphEntryInstr::constant_null() { |
465 ASSERT(initial_definitions_.length() > 0); | 463 ASSERT(initial_definitions_.length() > 0); |
(...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2544 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, | 2542 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, |
2545 GetDeoptId(), | 2543 GetDeoptId(), |
2546 Scanner::kNoSourcePos); | 2544 Scanner::kNoSourcePos); |
2547 } | 2545 } |
2548 if (HasParallelMove()) { | 2546 if (HasParallelMove()) { |
2549 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); | 2547 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); |
2550 } | 2548 } |
2551 } | 2549 } |
2552 | 2550 |
2553 | 2551 |
2554 void IndirectGotoInstr::ComputeOffsetTable(Isolate* isolate) { | |
2555 if (GetBlock()->offset() < 0) { | |
2556 // Don't generate a table when contained in an unreachable block. | |
2557 return; | |
2558 } | |
2559 ASSERT(SuccessorCount() == offsets_.Capacity()); | |
2560 offsets_.SetLength(SuccessorCount()); | |
2561 for (intptr_t i = 0; i < SuccessorCount(); i++) { | |
2562 TargetEntryInstr* target = SuccessorAt(i); | |
2563 intptr_t offset = target->offset(); | |
2564 | |
2565 // The intermediate block might be compacted, if so, use the indirect entry. | |
2566 if (offset < 0) { | |
2567 // Optimizations might have modified the immediate target block, but it | |
2568 // must end with a goto to the indirect entry. Also, we can't use | |
2569 // last_instruction because 'target' is compacted/unreachable. | |
2570 Instruction* last = target->next(); | |
2571 while (last != NULL && !last->IsGoto()) { | |
2572 last = last->next(); | |
2573 } | |
2574 ASSERT(last); | |
2575 IndirectEntryInstr* ientry = | |
2576 last->AsGoto()->successor()->AsIndirectEntry(); | |
2577 ASSERT(ientry != NULL); | |
2578 ASSERT(ientry->indirect_id() == i); | |
2579 offset = ientry->offset(); | |
2580 } | |
2581 | |
2582 ASSERT(offset > 0); | |
2583 offset -= Assembler::EntryPointToPcMarkerOffset(); | |
2584 offsets_.SetAt(i, Smi::ZoneHandle(isolate, Smi::New(offset))); | |
2585 } | |
2586 } | |
2587 | |
2588 | |
2589 LocationSummary* IndirectEntryInstr::MakeLocationSummary( | |
2590 Isolate* isolate, bool optimizing) const { | |
2591 return JoinEntryInstr::MakeLocationSummary(isolate, optimizing); | |
2592 } | |
2593 | |
2594 | |
2595 void IndirectEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
2596 JoinEntryInstr::EmitNativeCode(compiler); | |
2597 } | |
2598 | |
2599 | |
2600 LocationSummary* PhiInstr::MakeLocationSummary(Isolate* isolate, | 2552 LocationSummary* PhiInstr::MakeLocationSummary(Isolate* isolate, |
2601 bool optimizing) const { | 2553 bool optimizing) const { |
2602 UNREACHABLE(); | 2554 UNREACHABLE(); |
2603 return NULL; | 2555 return NULL; |
2604 } | 2556 } |
2605 | 2557 |
2606 | 2558 |
2607 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2559 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2608 UNREACHABLE(); | 2560 UNREACHABLE(); |
2609 } | 2561 } |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3380 case kIllegal: return "illegal"; | 3332 case kIllegal: return "illegal"; |
3381 case kSin: return "sin"; | 3333 case kSin: return "sin"; |
3382 case kCos: return "cos"; | 3334 case kCos: return "cos"; |
3383 case kSqrt: return "sqrt"; | 3335 case kSqrt: return "sqrt"; |
3384 case kDoubleSquare: return "double-square"; | 3336 case kDoubleSquare: return "double-square"; |
3385 } | 3337 } |
3386 UNREACHABLE(); | 3338 UNREACHABLE(); |
3387 return ""; | 3339 return ""; |
3388 } | 3340 } |
3389 | 3341 |
3390 typedef RawBool* (*CaseInsensitiveCompareUC16Function) ( | |
3391 RawString* string_raw, | |
3392 RawSmi* lhs_index_raw, | |
3393 RawSmi* rhs_index_raw, | |
3394 RawSmi* length_raw); | |
3395 | |
3396 | |
3397 extern const RuntimeEntry kCaseInsensitiveCompareUC16RuntimeEntry( | |
3398 "CaseInsensitiveCompareUC16", reinterpret_cast<RuntimeFunction>( | |
3399 static_cast<CaseInsensitiveCompareUC16Function>( | |
3400 &IRRegExpMacroAssembler::CaseInsensitiveCompareUC16)), 4, true, false); | |
3401 | |
3402 | |
3403 const RuntimeEntry& CaseInsensitiveCompareUC16Instr::TargetFunction() const { | |
3404 return kCaseInsensitiveCompareUC16RuntimeEntry; | |
3405 } | |
3406 | |
3407 | 3342 |
3408 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, | 3343 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, |
3409 intptr_t deopt_id, | 3344 intptr_t deopt_id, |
3410 MergedMathInstr::Kind kind) | 3345 MergedMathInstr::Kind kind) |
3411 : PureDefinition(deopt_id), | 3346 : PureDefinition(deopt_id), |
3412 inputs_(inputs), | 3347 inputs_(inputs), |
3413 kind_(kind) { | 3348 kind_(kind) { |
3414 ASSERT(inputs_->length() == InputCountFor(kind_)); | 3349 ASSERT(inputs_->length() == InputCountFor(kind_)); |
3415 for (intptr_t i = 0; i < inputs_->length(); ++i) { | 3350 for (intptr_t i = 0; i < inputs_->length(); ++i) { |
3416 ASSERT((*inputs)[i] != NULL); | 3351 ASSERT((*inputs)[i] != NULL); |
(...skipping 17 matching lines...) Expand all Loading... |
3434 case Token::kTRUNCDIV: return 0; | 3369 case Token::kTRUNCDIV: return 0; |
3435 case Token::kMOD: return 1; | 3370 case Token::kMOD: return 1; |
3436 default: UNIMPLEMENTED(); return -1; | 3371 default: UNIMPLEMENTED(); return -1; |
3437 } | 3372 } |
3438 } | 3373 } |
3439 | 3374 |
3440 | 3375 |
3441 #undef __ | 3376 #undef __ |
3442 | 3377 |
3443 } // namespace dart | 3378 } // namespace dart |
OLD | NEW |