Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to current version Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
20 #include "vm/resolver.h" 21 #include "vm/resolver.h"
21 #include "vm/scopes.h" 22 #include "vm/scopes.h"
22 #include "vm/stub_code.h" 23 #include "vm/stub_code.h"
23 #include "vm/symbols.h" 24 #include "vm/symbols.h"
24 25
25 #include "vm/il_printer.h" 26 #include "vm/il_printer.h"
26 27
27 namespace dart { 28 namespace dart {
28 29
29 DEFINE_FLAG(bool, propagate_ic_data, true, 30 DEFINE_FLAG(bool, propagate_ic_data, true,
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 364 }
364 365
365 366
366 bool LoadIndexedInstr::AttributesEqual(Instruction* other) const { 367 bool LoadIndexedInstr::AttributesEqual(Instruction* other) const {
367 LoadIndexedInstr* other_load = other->AsLoadIndexed(); 368 LoadIndexedInstr* other_load = other->AsLoadIndexed();
368 ASSERT(other_load != NULL); 369 ASSERT(other_load != NULL);
369 return class_id() == other_load->class_id(); 370 return class_id() == other_load->class_id();
370 } 371 }
371 372
372 373
374 bool LoadCodeUnitsInstr::AttributesEqual(Instruction* other) const {
375 LoadCodeUnitsInstr* other_load = other->AsLoadCodeUnits();
376 ASSERT(other_load != NULL);
377 return (class_id() == other_load->class_id() &&
378 element_count() == other_load->element_count());
379 }
380
381
373 ConstantInstr::ConstantInstr(const Object& value) : value_(value) { 382 ConstantInstr::ConstantInstr(const Object& value) : value_(value) {
374 // Check that the value is not an incorrect Integer representation. 383 // Check that the value is not an incorrect Integer representation.
375 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoSmi()); 384 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoSmi());
376 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoInt64()); 385 ASSERT(!value.IsBigint() || !Bigint::Cast(value).FitsIntoInt64());
377 ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).AsInt64Value())); 386 ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).AsInt64Value()));
378 } 387 }
379 388
380 389
381 bool ConstantInstr::AttributesEqual(Instruction* other) const { 390 bool ConstantInstr::AttributesEqual(Instruction* other) const {
382 ConstantInstr* other_constant = other->AsConstant(); 391 ConstantInstr* other_constant = other->AsConstant();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 462 }
454 463
455 464
456 GraphEntryInstr::GraphEntryInstr(const ParsedFunction* parsed_function, 465 GraphEntryInstr::GraphEntryInstr(const ParsedFunction* parsed_function,
457 TargetEntryInstr* normal_entry, 466 TargetEntryInstr* normal_entry,
458 intptr_t osr_id) 467 intptr_t osr_id)
459 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), 468 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex),
460 parsed_function_(parsed_function), 469 parsed_function_(parsed_function),
461 normal_entry_(normal_entry), 470 normal_entry_(normal_entry),
462 catch_entries_(), 471 catch_entries_(),
472 indirect_entries_(),
463 initial_definitions_(), 473 initial_definitions_(),
464 osr_id_(osr_id), 474 osr_id_(osr_id),
465 entry_count_(0), 475 entry_count_(0),
466 spill_slot_count_(0), 476 spill_slot_count_(0),
467 fixed_slot_count_(0) { 477 fixed_slot_count_(0) {
468 } 478 }
469 479
470 480
471 ConstantInstr* GraphEntryInstr::constant_null() { 481 ConstantInstr* GraphEntryInstr::constant_null() {
472 ASSERT(initial_definitions_.length() > 0); 482 ASSERT(initial_definitions_.length() > 0);
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 return NULL; 1126 return NULL;
1117 } 1127 }
1118 1128
1119 1129
1120 intptr_t GraphEntryInstr::SuccessorCount() const { 1130 intptr_t GraphEntryInstr::SuccessorCount() const {
1121 return 1 + catch_entries_.length(); 1131 return 1 + catch_entries_.length();
1122 } 1132 }
1123 1133
1124 1134
1125 BlockEntryInstr* GraphEntryInstr::SuccessorAt(intptr_t index) const { 1135 BlockEntryInstr* GraphEntryInstr::SuccessorAt(intptr_t index) const {
1126 if (index == 0) return normal_entry_; 1136 if (index == 0) {
1127 return catch_entries_[index - 1]; 1137 return normal_entry_;
1138 } else {
1139 ASSERT(index < catch_entries_.length() + 1);
srdjan 2014/09/22 22:34:07 Add parentheses.
jgruber1 2014/09/23 10:58:46 Reverted this change since it was functionally ide
1140 return catch_entries_[index - 1];
1141 }
1128 } 1142 }
1129 1143
1130 1144
1131 intptr_t BranchInstr::SuccessorCount() const { 1145 intptr_t BranchInstr::SuccessorCount() const {
1132 return 2; 1146 return 2;
1133 } 1147 }
1134 1148
1135 1149
1136 BlockEntryInstr* BranchInstr::SuccessorAt(intptr_t index) const { 1150 BlockEntryInstr* BranchInstr::SuccessorAt(intptr_t index) const {
1137 if (index == 0) return true_successor_; 1151 if (index == 0) return true_successor_;
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 1783
1770 1784
1771 // A math unary instruction has a side effect (exception 1785 // A math unary instruction has a side effect (exception
1772 // thrown) if the argument is not a number. 1786 // thrown) if the argument is not a number.
1773 // TODO(srdjan): eliminate if has no uses and input is guaranteed to be number. 1787 // TODO(srdjan): eliminate if has no uses and input is guaranteed to be number.
1774 Definition* MathUnaryInstr::Canonicalize(FlowGraph* flow_graph) { 1788 Definition* MathUnaryInstr::Canonicalize(FlowGraph* flow_graph) {
1775 return this; 1789 return this;
1776 } 1790 }
1777 1791
1778 1792
1793 Definition* CaseInsensitiveCompareUC16Instr::Canonicalize(
1794 FlowGraph* flow_graph) {
1795 return this;
1796 }
1797
1798
1779 Definition* LoadFieldInstr::Canonicalize(FlowGraph* flow_graph) { 1799 Definition* LoadFieldInstr::Canonicalize(FlowGraph* flow_graph) {
1780 if (!HasUses()) return NULL; 1800 if (!HasUses()) return NULL;
1781 if (!IsImmutableLengthLoad()) return this; 1801 if (!IsImmutableLengthLoad()) return this;
1782 1802
1783 // For fixed length arrays if the array is the result of a known constructor 1803 // For fixed length arrays if the array is the result of a known constructor
1784 // call we can replace the length load with the length argument passed to 1804 // call we can replace the length load with the length argument passed to
1785 // the constructor. 1805 // the constructor.
1786 StaticCallInstr* call = instance()->definition()->AsStaticCall(); 1806 StaticCallInstr* call = instance()->definition()->AsStaticCall();
1787 if (call != NULL) { 1807 if (call != NULL) {
1788 if (call->is_known_list_constructor() && 1808 if (call->is_known_list_constructor() &&
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, 2521 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt,
2502 deopt_id_, 2522 deopt_id_,
2503 Scanner::kNoSourcePos); 2523 Scanner::kNoSourcePos);
2504 } 2524 }
2505 if (HasParallelMove()) { 2525 if (HasParallelMove()) {
2506 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 2526 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
2507 } 2527 }
2508 } 2528 }
2509 2529
2510 2530
2531 LocationSummary* IndirectEntryInstr::MakeLocationSummary(
2532 Isolate* isolate, bool optimizing) const {
2533 UNREACHABLE();
2534 return NULL;
2535 }
2536
2537
2511 LocationSummary* PhiInstr::MakeLocationSummary(Isolate* isolate, 2538 LocationSummary* PhiInstr::MakeLocationSummary(Isolate* isolate,
2512 bool optimizing) const { 2539 bool optimizing) const {
2513 UNREACHABLE(); 2540 UNREACHABLE();
2514 return NULL; 2541 return NULL;
2515 } 2542 }
2516 2543
2517 2544
2518 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2545 void PhiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2519 UNREACHABLE(); 2546 UNREACHABLE();
2520 } 2547 }
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
3281 case kIllegal: return "illegal"; 3308 case kIllegal: return "illegal";
3282 case kSin: return "sin"; 3309 case kSin: return "sin";
3283 case kCos: return "cos"; 3310 case kCos: return "cos";
3284 case kSqrt: return "sqrt"; 3311 case kSqrt: return "sqrt";
3285 case kDoubleSquare: return "double-square"; 3312 case kDoubleSquare: return "double-square";
3286 } 3313 }
3287 UNREACHABLE(); 3314 UNREACHABLE();
3288 return ""; 3315 return "";
3289 } 3316 }
3290 3317
3318 typedef RawBool* (*CaseInsensitiveCompareUC16Function) (
3319 RawString* string_raw,
3320 RawSmi* lhs_index_raw,
3321 RawSmi* rhs_index_raw,
3322 RawSmi* length_raw);
3323
3324
3325 extern const RuntimeEntry kCaseInsensitiveCompareUC16RuntimeEntry(
3326 "CaseInsensitiveCompareUC16", reinterpret_cast<RuntimeFunction>(
3327 static_cast<CaseInsensitiveCompareUC16Function>(
3328 &IRRegExpMacroAssembler::CaseInsensitiveCompareUC16)), 4, true, false);
3329
3330
3331 const RuntimeEntry& CaseInsensitiveCompareUC16Instr::TargetFunction() const {
3332 return kCaseInsensitiveCompareUC16RuntimeEntry;
3333 }
3334
3291 3335
3292 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs, 3336 MergedMathInstr::MergedMathInstr(ZoneGrowableArray<Value*>* inputs,
3293 intptr_t original_deopt_id, 3337 intptr_t original_deopt_id,
3294 MergedMathInstr::Kind kind) 3338 MergedMathInstr::Kind kind)
3295 : inputs_(inputs), 3339 : inputs_(inputs),
3296 kind_(kind) { 3340 kind_(kind) {
3297 ASSERT(inputs_->length() == InputCountFor(kind_)); 3341 ASSERT(inputs_->length() == InputCountFor(kind_));
3298 for (intptr_t i = 0; i < inputs_->length(); ++i) { 3342 for (intptr_t i = 0; i < inputs_->length(); ++i) {
3299 ASSERT((*inputs)[i] != NULL); 3343 ASSERT((*inputs)[i] != NULL);
3300 (*inputs)[i]->set_instruction(this); 3344 (*inputs)[i]->set_instruction(this);
(...skipping 17 matching lines...) Expand all
3318 case Token::kTRUNCDIV: return 0; 3362 case Token::kTRUNCDIV: return 0;
3319 case Token::kMOD: return 1; 3363 case Token::kMOD: return 1;
3320 default: UNIMPLEMENTED(); return -1; 3364 default: UNIMPLEMENTED(); return -1;
3321 } 3365 }
3322 } 3366 }
3323 3367
3324 3368
3325 #undef __ 3369 #undef __
3326 3370
3327 } // namespace dart 3371 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698