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

Side by Side Diff: runtime/vm/intermediate_language_arm64.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, 3 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
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"
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 __ SmiTag(result); 1127 __ SmiTag(result);
1128 break; 1128 break;
1129 default: 1129 default:
1130 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); 1130 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid));
1131 __ ldr(result, element_address); 1131 __ ldr(result, element_address);
1132 break; 1132 break;
1133 } 1133 }
1134 } 1134 }
1135 1135
1136 1136
1137 CompileType LoadCodeUnitsInstr::ComputeType() const {
1138 switch (class_id()) {
1139 case kOneByteStringCid:
1140 case kTwoByteStringCid:
1141 case kExternalOneByteStringCid:
1142 case kExternalTwoByteStringCid:
1143 return CompileType::FromCid(kSmiCid);
1144 default:
1145 UNIMPLEMENTED();
1146 return CompileType::Dynamic();
1147 }
1148 }
1149
1150
1151 Representation LoadCodeUnitsInstr::representation() const {
1152 switch (class_id()) {
1153 case kOneByteStringCid:
1154 case kTwoByteStringCid:
1155 case kExternalOneByteStringCid:
1156 case kExternalTwoByteStringCid:
1157 return kTagged;
1158 default:
1159 UNIMPLEMENTED();
1160 return kTagged;
1161 }
1162 }
1163
1164
1165 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate,
1166 bool opt) const {
1167 const intptr_t kNumInputs = 2;
1168 const intptr_t kNumTemps = 0;
1169 LocationSummary* locs = new(isolate) LocationSummary(
1170 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
1171 locs->set_in(0, Location::RequiresRegister());
1172 if (CanBeImmediateIndex(index(), class_id(), IsExternal())) {
1173 locs->set_in(1, Location::Constant(index()->definition()->AsConstant()));
1174 } else {
1175 locs->set_in(1, Location::RequiresRegister());
1176 }
1177
1178 locs->set_out(0, Location::RequiresRegister());
1179 return locs;
1180 }
1181
1182
1183 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1184 const Register array = locs()->in(0).reg();
1185 const Location index = locs()->in(1);
1186
1187 Address element_address = index.IsRegister()
1188 ? __ ElementAddressForRegIndex(true, // Load.
1189 IsExternal(), class_id(), index_scale(),
1190 array, index.reg())
1191 : __ ElementAddressForIntIndex(
1192 IsExternal(), class_id(), index_scale(),
1193 array, Smi::Cast(index.constant()).Value());
1194 // Warning: element_address may use register TMP as base.
1195
1196 Register result = locs()->out(0).reg();
1197 switch (class_id()) {
1198 case kOneByteStringCid:
1199 case kExternalOneByteStringCid:
1200 switch (element_count()) {
1201 case 1: __ ldr(result, element_address, kUnsignedByte); break;
1202 case 2: __ ldr(result, element_address, kUnsignedHalfword); break;
1203 case 4: __ ldr(result, element_address, kUnsignedWord); break;
1204 default: UNREACHABLE();
1205 }
1206 __ SmiTag(result);
1207 break;
1208 case kTwoByteStringCid:
1209 case kExternalTwoByteStringCid:
1210 switch (element_count()) {
1211 case 1: __ ldr(result, element_address, kUnsignedHalfword); break;
1212 case 2: __ ldr(result, element_address, kUnsignedWord); break;
1213 default: UNREACHABLE();
1214 }
1215 __ SmiTag(result);
1216 break;
1217 default:
1218 UNREACHABLE();
1219 break;
1220 }
1221 }
1222
1223
1137 Representation StoreIndexedInstr::RequiredInputRepresentation( 1224 Representation StoreIndexedInstr::RequiredInputRepresentation(
1138 intptr_t idx) const { 1225 intptr_t idx) const {
1139 // Array can be a Dart object or a pointer to external data. 1226 // Array can be a Dart object or a pointer to external data.
1140 if (idx == 0) return kNoRepresentation; // Flexible input representation. 1227 if (idx == 0) return kNoRepresentation; // Flexible input representation.
1141 if (idx == 1) return kTagged; // Index is a smi. 1228 if (idx == 1) return kTagged; // Index is a smi.
1142 ASSERT(idx == 2); 1229 ASSERT(idx == 2);
1143 switch (class_id_) { 1230 switch (class_id_) {
1144 case kArrayCid: 1231 case kArrayCid:
1145 case kOneByteStringCid: 1232 case kOneByteStringCid:
1146 case kTypedDataInt8ArrayCid: 1233 case kTypedDataInt8ArrayCid:
(...skipping 3086 matching lines...) Expand 10 before | Expand all | Expand 10 after
4233 const VRegister result = locs()->out(0).fpu_reg(); 4320 const VRegister result = locs()->out(0).fpu_reg();
4234 __ fmuld(result, val, val); 4321 __ fmuld(result, val, val);
4235 } else { 4322 } else {
4236 ASSERT((kind() == MathUnaryInstr::kSin) || 4323 ASSERT((kind() == MathUnaryInstr::kSin) ||
4237 (kind() == MathUnaryInstr::kCos)); 4324 (kind() == MathUnaryInstr::kCos));
4238 __ CallRuntime(TargetFunction(), InputCount()); 4325 __ CallRuntime(TargetFunction(), InputCount());
4239 } 4326 }
4240 } 4327 }
4241 4328
4242 4329
4330 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary(
4331 Isolate* isolate, bool opt) const {
4332 const intptr_t kNumTemps = 0;
4333 LocationSummary* summary = new(isolate) LocationSummary(
4334 isolate, InputCount(), kNumTemps, LocationSummary::kCall);
4335 summary->set_in(0, Location::RegisterLocation(R0));
4336 summary->set_in(1, Location::RegisterLocation(R1));
4337 summary->set_in(2, Location::RegisterLocation(R2));
4338 summary->set_in(3, Location::RegisterLocation(R3));
4339 summary->set_out(0, Location::RegisterLocation(R0));
4340 return summary;
4341 }
4342
4343
4344 void CaseInsensitiveCompareUC16Instr::EmitNativeCode(
4345 FlowGraphCompiler* compiler) {
4346
4347 // Call the function.
4348 __ CallRuntime(TargetFunction(), TargetFunction().argument_count());
4349 }
4350
4351
4243 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, 4352 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate,
4244 bool opt) const { 4353 bool opt) const {
4245 if (result_cid() == kDoubleCid) { 4354 if (result_cid() == kDoubleCid) {
4246 const intptr_t kNumInputs = 2; 4355 const intptr_t kNumInputs = 2;
4247 const intptr_t kNumTemps = 0; 4356 const intptr_t kNumTemps = 0;
4248 LocationSummary* summary = new(isolate) LocationSummary( 4357 LocationSummary* summary = new(isolate) LocationSummary(
4249 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4358 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4250 summary->set_in(0, Location::RequiresFpuRegister()); 4359 summary->set_in(0, Location::RequiresFpuRegister());
4251 summary->set_in(1, Location::RequiresFpuRegister()); 4360 summary->set_in(1, Location::RequiresFpuRegister());
4252 // Reuse the left register so that code can be made shorter. 4361 // Reuse the left register so that code can be made shorter.
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
5309 } 5418 }
5310 5419
5311 5420
5312 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5421 void GraphEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5313 if (!compiler->CanFallThroughTo(normal_entry())) { 5422 if (!compiler->CanFallThroughTo(normal_entry())) {
5314 __ b(compiler->GetJumpLabel(normal_entry())); 5423 __ b(compiler->GetJumpLabel(normal_entry()));
5315 } 5424 }
5316 } 5425 }
5317 5426
5318 5427
5428 void IndirectEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5429 __ Bind(compiler->GetJumpLabel(this));
5430 if (!compiler->is_optimizing()) {
5431 compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt,
5432 deopt_id_,
5433 Scanner::kNoSourcePos);
5434 }
5435 if (HasParallelMove()) {
5436 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
5437 }
5438 }
5439
5440
5319 LocationSummary* GotoInstr::MakeLocationSummary(Isolate* isolate, 5441 LocationSummary* GotoInstr::MakeLocationSummary(Isolate* isolate,
5320 bool opt) const { 5442 bool opt) const {
5321 return new(isolate) LocationSummary(isolate, 0, 0, LocationSummary::kNoCall); 5443 return new(isolate) LocationSummary(isolate, 0, 0, LocationSummary::kNoCall);
5322 } 5444 }
5323 5445
5324 5446
5325 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5447 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5326 if (!compiler->is_optimizing()) { 5448 if (!compiler->is_optimizing()) {
5327 if (FLAG_emit_edge_counters) { 5449 if (FLAG_emit_edge_counters) {
5328 compiler->EmitEdgeCounter(); 5450 compiler->EmitEdgeCounter();
(...skipping 12 matching lines...) Expand all
5341 } 5463 }
5342 5464
5343 // We can fall through if the successor is the next block in the list. 5465 // We can fall through if the successor is the next block in the list.
5344 // Otherwise, we need a jump. 5466 // Otherwise, we need a jump.
5345 if (!compiler->CanFallThroughTo(successor())) { 5467 if (!compiler->CanFallThroughTo(successor())) {
5346 __ b(compiler->GetJumpLabel(successor())); 5468 __ b(compiler->GetJumpLabel(successor()));
5347 } 5469 }
5348 } 5470 }
5349 5471
5350 5472
5473 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate,
5474 bool opt) const {
5475 const intptr_t kNumInputs = 1;
5476 const intptr_t kNumTemps = 1;
5477
5478 LocationSummary* locs = new(isolate) LocationSummary(
5479 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5480
5481 locs->set_in(0, Location::RequiresRegister());
5482 locs->set_temp(0, Location::RequiresRegister());
5483
5484 return locs;
5485 }
5486
5487
5488 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5489 Register sum_reg = locs()->temp_slot(0)->reg();
5490
5491 // Load from [current frame pointer] + kPcMarkerSlotFromFp.
5492 __ ldr(sum_reg, Address(FP, kPcMarkerSlotFromFp * kWordSize));
5493
5494 // Subtract the entrypoint offset.
5495 __ AddImmediate(sum_reg,
5496 sum_reg,
5497 -Assembler::EntryPointToPcMarkerOffset(),
5498 PP);
5499
5500 // Add the offset.
5501 Register offset_reg = locs()->in(0).reg();
5502 __ SmiUntag(offset_reg);
5503 __ add(sum_reg, sum_reg, Operand(offset_reg));
5504
5505 // Jump to the absolute address.
5506 __ br(sum_reg);
5507 }
5508
5509
5351 LocationSummary* CurrentContextInstr::MakeLocationSummary(Isolate* isolate, 5510 LocationSummary* CurrentContextInstr::MakeLocationSummary(Isolate* isolate,
5352 bool opt) const { 5511 bool opt) const {
5353 return LocationSummary::Make(isolate, 5512 return LocationSummary::Make(isolate,
5354 0, 5513 0,
5355 Location::RequiresRegister(), 5514 Location::RequiresRegister(),
5356 LocationSummary::kNoCall); 5515 LocationSummary::kNoCall);
5357 } 5516 }
5358 5517
5359 5518
5360 void CurrentContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5519 void CurrentContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
5490 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 5649 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
5491 #if defined(DEBUG) 5650 #if defined(DEBUG)
5492 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); 5651 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP);
5493 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); 5652 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP);
5494 #endif 5653 #endif
5495 } 5654 }
5496 5655
5497 } // namespace dart 5656 } // namespace dart
5498 5657
5499 #endif // defined TARGET_ARCH_ARM64 5658 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698