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

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

Issue 11049011: Fix crashes in Smi equality comparisons: Smi equality instruction may have null as inputs. Null is … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « no previous file | 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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 __ jmp(&done); 567 __ jmp(&done);
568 __ Bind(&non_null_compare); // Receiver is not null. 568 __ Bind(&non_null_compare); // Receiver is not null.
569 __ pushl(left); 569 __ pushl(left);
570 __ pushl(right); 570 __ pushl(right);
571 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind, 571 EmitEqualityAsPolymorphicCall(compiler, ic_data, locs, branch, kind,
572 deopt_id, token_pos); 572 deopt_id, token_pos);
573 __ Bind(&done); 573 __ Bind(&done);
574 } 574 }
575 575
576 576
577 Immediate SmiConstantToImmediate(const Object& constant) {
578 ASSERT(constant.IsSmi());
579 return Immediate(reinterpret_cast<int32_t>(constant.raw()));
580 }
581
582
583 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler, 577 static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
584 const LocationSummary& locs, 578 const LocationSummary& locs,
585 Token::Kind kind, 579 Token::Kind kind,
586 BranchInstr* branch) { 580 BranchInstr* branch) {
587 Location left = locs.in(0); 581 Location left = locs.in(0);
588 Location right = locs.in(1); 582 Location right = locs.in(1);
589 583
590 Condition true_condition = TokenKindToSmiCondition(kind); 584 Condition true_condition = TokenKindToSmiCondition(kind);
591 585
592 if (left.IsConstant() && right.IsConstant()) { 586 if (left.IsConstant() && right.IsConstant()) {
593 // TODO(vegorov): should be eliminated earlier by constant propagation. 587 // TODO(vegorov): should be eliminated earlier by constant propagation.
594 const bool result = FlowGraphCompiler::EvaluateCondition( 588 const bool result = FlowGraphCompiler::EvaluateCondition(
595 true_condition, 589 true_condition,
596 Smi::Cast(left.constant()).Value(), 590 Smi::Cast(left.constant()).Value(),
597 Smi::Cast(right.constant()).Value()); 591 Smi::Cast(right.constant()).Value());
598 592
599 if (branch != NULL) { 593 if (branch != NULL) {
600 branch->EmitBranchOnValue(compiler, result); 594 branch->EmitBranchOnValue(compiler, result);
601 } else { 595 } else {
602 __ LoadObject(locs.out().reg(), result ? compiler->bool_true() 596 __ LoadObject(locs.out().reg(), result ? compiler->bool_true()
603 : compiler->bool_false()); 597 : compiler->bool_false());
604 } 598 }
605 599
606 return; 600 return;
607 } 601 }
608 602
609 if (left.IsConstant()) { 603 if (left.IsConstant()) {
610 __ cmpl(right.reg(), SmiConstantToImmediate(left.constant())); 604 __ CompareObject(right.reg(), left.constant());
611 true_condition = FlowGraphCompiler::FlipCondition(true_condition); 605 true_condition = FlowGraphCompiler::FlipCondition(true_condition);
612 } else if (right.IsConstant()) { 606 } else if (right.IsConstant()) {
613 __ cmpl(left.reg(), SmiConstantToImmediate(right.constant())); 607 __ CompareObject(left.reg(), right.constant());
614 } else { 608 } else {
615 __ cmpl(left.reg(), right.reg()); 609 __ cmpl(left.reg(), right.reg());
616 } 610 }
617 611
618 if (branch != NULL) { 612 if (branch != NULL) {
619 branch->EmitBranchOnCondition(compiler, true_condition); 613 branch->EmitBranchOnCondition(compiler, true_condition);
620 } else { 614 } else {
621 Register result = locs.out().reg(); 615 Register result = locs.out().reg();
622 Label done, is_true; 616 Label done, is_true;
623 __ j(true_condition, &is_true); 617 __ j(true_condition, &is_true);
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 } 2437 }
2444 } 2438 }
2445 2439
2446 2440
2447 2441
2448 } // namespace dart 2442 } // namespace dart
2449 2443
2450 #undef __ 2444 #undef __
2451 2445
2452 #endif // defined TARGET_ARCH_X64 2446 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698