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

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

Issue 10534105: Implement is32 LoadIndexed. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 __ movl(EDX, Immediate(argument_count())); 395 __ movl(EDX, Immediate(argument_count()));
396 compiler->GenerateCall(token_index(), 396 compiler->GenerateCall(token_index(),
397 try_index(), 397 try_index(),
398 &StubCode::CallNativeCFunctionLabel(), 398 &StubCode::CallNativeCFunctionLabel(),
399 PcDescriptors::kOther); 399 PcDescriptors::kOther);
400 __ popl(result); 400 __ popl(result);
401 } 401 }
402 402
403 403
404 LocationSummary* LoadIndexedComp::MakeLocationSummary() const { 404 LocationSummary* LoadIndexedComp::MakeLocationSummary() const {
405 return MakeCallSummary(); 405 const intptr_t kNumInputs = 2;
406 if ((receiver_type() == kGrowableObjectArray) ||
407 (receiver_type() == kArray) ||
408 (receiver_type() == kImmutableArray)) {
409 const intptr_t kNumTemps = 1;
410 LocationSummary* locs = new LocationSummary(kNumInputs, kNumTemps);
411 locs->set_in(0, Location::RequiresRegister());
412 locs->set_in(1, Location::RequiresRegister());
413 locs->set_temp(0, Location::RequiresRegister());
414 locs->set_out(Location::RequiresRegister());
415 return locs;
416 } else {
417 ASSERT(receiver_type() == kIllegalObjectKind);
418 return MakeCallSummary();
419 }
406 } 420 }
407 421
408 422
423
409 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { 424 void LoadIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) {
410 const String& function_name = 425 if (receiver_type() == kIllegalObjectKind) {
411 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX))); 426 compiler->EmitLoadIndexedGeneric(this);
427 ASSERT(locs()->out().reg() == EAX);
428 return;
429 }
430 Register receiver = locs()->in(0).reg();
431 Register index = locs()->in(1).reg();
432 Register result = locs()->out().reg();
433 Register temp = locs()->temp(0).reg();
412 434
413 const intptr_t kNumArguments = 2; 435 const Class& receiver_class =
414 const intptr_t kNumArgsChecked = 1; // Type-feedback. 436 Class::ZoneHandle(Isolate::Current()->class_table()->At(
415 compiler->GenerateInstanceCall(cid(), 437 receiver_type()));
416 token_index(), 438
417 try_index(), 439 const DeoptReasonId deopt_reason = (receiver_type() == kGrowableObjectArray) ?
418 function_name, 440 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
419 kNumArguments, 441
420 Array::ZoneHandle(), // No optional arguments. 442 Label* deopt = compiler->AddDeoptStub(cid(),
421 kNumArgsChecked); 443 token_index(),
444 try_index(),
445 deopt_reason,
446 receiver,
447 index);
448
449 __ testl(receiver, Immediate(kSmiTagMask)); // Deoptimize if Smi.
450 __ j(ZERO, deopt);
451 __ CompareClassId(receiver, receiver_class.id(), temp);
452 __ j(NOT_EQUAL, deopt);
453
454 __ testl(index, Immediate(kSmiTagMask));
455 __ j(NOT_ZERO, deopt);
456
457 switch (receiver_type()) {
458 case kArray:
459 case kImmutableArray:
460 __ cmpl(index, FieldAddress(receiver, Array::length_offset()));
461 __ j(ABOVE_EQUAL, deopt);
462 // Note that index is Smi, i.e, times 2.
463 ASSERT(kSmiTagShift == 1);
464 __ movl(result, FieldAddress(receiver, index, TIMES_2, sizeof(RawArray)));
465 break;
466
467 case kGrowableObjectArray: {
468 Register temp = locs()->temp(0).reg();
469
470 __ cmpl(index,
471 FieldAddress(receiver, GrowableObjectArray::length_offset()));
472 __ j(ABOVE_EQUAL, deopt);
473 __ movl(temp, FieldAddress(receiver, GrowableObjectArray::data_offset()));
474 // Note that index is Smi, i.e, times 2.
475 ASSERT(kSmiTagShift == 1);
476 __ movl(result, FieldAddress(temp, index, TIMES_2, sizeof(RawArray)));
477 break;
478 }
479
480 default:
481 UNREACHABLE();
482 break;
483 }
422 } 484 }
423 485
424 486
425 LocationSummary* StoreIndexedComp::MakeLocationSummary() const { 487 LocationSummary* StoreIndexedComp::MakeLocationSummary() const {
426 const intptr_t kNumInputs = 3; 488 const intptr_t kNumInputs = 3;
427 return LocationSummary::Make(kNumInputs, Location::NoLocation()); 489 return LocationSummary::Make(kNumInputs, Location::NoLocation());
428 } 490 }
429 491
430 492
431 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) { 493 void StoreIndexedComp::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 UNREACHABLE(); 1309 UNREACHABLE();
1248 } 1310 }
1249 } 1311 }
1250 1312
1251 1313
1252 } // namespace dart 1314 } // namespace dart
1253 1315
1254 #undef __ 1316 #undef __
1255 1317
1256 #endif // defined TARGET_ARCH_X64 1318 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698