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

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

Issue 23454032: - Tighten assertions in the X64 assembler related to object pool usage. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intrinsifier_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) 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/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if (!compiler->is_optimizing()) { 447 if (!compiler->is_optimizing()) {
448 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, 448 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
449 deopt_id, 449 deopt_id,
450 token_pos); 450 token_pos);
451 } 451 }
452 const int kNumberOfArguments = 2; 452 const int kNumberOfArguments = 2;
453 const Array& kNoArgumentNames = Object::null_array(); 453 const Array& kNoArgumentNames = Object::null_array();
454 const int kNumArgumentsChecked = 2; 454 const int kNumArgumentsChecked = 2;
455 455
456 Label check_identity; 456 Label check_identity;
457 __ LoadObject(TMP, Object::Handle(), PP); 457 __ LoadObject(TMP, Object::null_object(), PP);
458 __ cmpq(Address(RSP, 0 * kWordSize), TMP); 458 __ cmpq(Address(RSP, 0 * kWordSize), TMP);
459 __ j(EQUAL, &check_identity); 459 __ j(EQUAL, &check_identity);
460 __ cmpq(Address(RSP, 1 * kWordSize), TMP); 460 __ cmpq(Address(RSP, 1 * kWordSize), TMP);
461 __ j(EQUAL, &check_identity); 461 __ j(EQUAL, &check_identity);
462 462
463 ICData& equality_ic_data = ICData::ZoneHandle(original_ic_data.raw()); 463 ICData& equality_ic_data = ICData::ZoneHandle(original_ic_data.raw());
464 if (compiler->is_optimizing() && FLAG_propagate_ic_data) { 464 if (compiler->is_optimizing() && FLAG_propagate_ic_data) {
465 ASSERT(!original_ic_data.IsNull()); 465 ASSERT(!original_ic_data.IsNull());
466 if (original_ic_data.NumberOfChecks() == 0) { 466 if (original_ic_data.NumberOfChecks() == 0) {
467 // IC call for reoptimization populates original ICData. 467 // IC call for reoptimization populates original ICData.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); 648 ASSERT((kind == Token::kEQ) || (kind == Token::kNE));
649 Register left = locs.in(0).reg(); 649 Register left = locs.in(0).reg();
650 Register right = locs.in(1).reg(); 650 Register right = locs.in(1).reg();
651 Register temp = locs.temp(0).reg(); 651 Register temp = locs.temp(0).reg();
652 Label* deopt = compiler->AddDeoptStub(deopt_id, kDeoptEquality); 652 Label* deopt = compiler->AddDeoptStub(deopt_id, kDeoptEquality);
653 __ testq(left, Immediate(kSmiTagMask)); 653 __ testq(left, Immediate(kSmiTagMask));
654 __ j(ZERO, deopt); 654 __ j(ZERO, deopt);
655 // 'left' is not Smi. 655 // 'left' is not Smi.
656 656
657 Label identity_compare; 657 Label identity_compare;
658 __ CompareObject(right, Object::Handle()); 658 __ CompareObject(right, Object::null_object());
659 __ j(EQUAL, &identity_compare); 659 __ j(EQUAL, &identity_compare);
660 __ CompareObject(left, Object::Handle()); 660 __ CompareObject(left, Object::null_object());
661 __ j(EQUAL, &identity_compare); 661 __ j(EQUAL, &identity_compare);
662 662
663 __ LoadClassId(temp, left); 663 __ LoadClassId(temp, left);
664 const ICData& ic_data = ICData::Handle(orig_ic_data.AsUnaryClassChecks()); 664 const ICData& ic_data = ICData::Handle(orig_ic_data.AsUnaryClassChecks());
665 const intptr_t len = ic_data.NumberOfChecks(); 665 const intptr_t len = ic_data.NumberOfChecks();
666 for (intptr_t i = 0; i < len; i++) { 666 for (intptr_t i = 0; i < len; i++) {
667 __ cmpq(temp, Immediate(ic_data.GetReceiverClassIdAt(i))); 667 __ cmpq(temp, Immediate(ic_data.GetReceiverClassIdAt(i)));
668 if (i == (len - 1)) { 668 if (i == (len - 1)) {
669 __ j(NOT_EQUAL, deopt); 669 __ j(NOT_EQUAL, deopt);
670 } else { 670 } else {
(...skipping 28 matching lines...) Expand all
699 BranchInstr* branch, 699 BranchInstr* branch,
700 const ICData& ic_data, 700 const ICData& ic_data,
701 intptr_t deopt_id, 701 intptr_t deopt_id,
702 intptr_t token_pos) { 702 intptr_t token_pos) {
703 ASSERT((kind == Token::kEQ) || (kind == Token::kNE)); 703 ASSERT((kind == Token::kEQ) || (kind == Token::kNE));
704 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfChecks() > 0)); 704 ASSERT(!ic_data.IsNull() && (ic_data.NumberOfChecks() > 0));
705 Register left = locs->in(0).reg(); 705 Register left = locs->in(0).reg();
706 Register right = locs->in(1).reg(); 706 Register right = locs->in(1).reg();
707 707
708 Label done, identity_compare, non_null_compare; 708 Label done, identity_compare, non_null_compare;
709 __ CompareObject(right, Object::Handle()); 709 __ CompareObject(right, Object::null_object());
710 __ j(EQUAL, &identity_compare, Assembler::kNearJump); 710 __ j(EQUAL, &identity_compare, Assembler::kNearJump);
711 __ CompareObject(left, Object::Handle()); 711 __ CompareObject(left, Object::null_object());
712 __ j(NOT_EQUAL, &non_null_compare, Assembler::kNearJump); 712 __ j(NOT_EQUAL, &non_null_compare, Assembler::kNearJump);
713 // Comparison with NULL is "===". 713 // Comparison with NULL is "===".
714 __ Bind(&identity_compare); 714 __ Bind(&identity_compare);
715 __ cmpq(left, right); 715 __ cmpq(left, right);
716 Condition cond = TokenKindToSmiCondition(kind); 716 Condition cond = TokenKindToSmiCondition(kind);
717 if (branch != NULL) { 717 if (branch != NULL) {
718 branch->EmitBranchOnCondition(compiler, cond); 718 branch->EmitBranchOnCondition(compiler, cond);
719 } else { 719 } else {
720 Register result = locs->out().reg(); 720 Register result = locs->out().reg();
721 Label load_true; 721 Label load_true;
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 } else if (RawObject::IsTypedDataClassId(field_cid)) { 1725 } else if (RawObject::IsTypedDataClassId(field_cid)) {
1726 // Destroy value_cid_reg (safe because we are finished with it). 1726 // Destroy value_cid_reg (safe because we are finished with it).
1727 __ movq(value_cid_reg, 1727 __ movq(value_cid_reg,
1728 FieldAddress(value_reg, TypedData::length_offset())); 1728 FieldAddress(value_reg, TypedData::length_offset()));
1729 } 1729 }
1730 __ cmpq(value_cid_reg, field_length_operand); 1730 __ cmpq(value_cid_reg, field_length_operand);
1731 } 1731 }
1732 1732
1733 if (field().is_nullable() && (field_cid != kNullCid)) { 1733 if (field().is_nullable() && (field_cid != kNullCid)) {
1734 __ j(EQUAL, &ok); 1734 __ j(EQUAL, &ok);
1735 __ CompareObject(value_reg, Object::Handle()); 1735 __ CompareObject(value_reg, Object::null_object());
1736 } 1736 }
1737 1737
1738 if (ok_is_fall_through) { 1738 if (ok_is_fall_through) {
1739 __ j(NOT_EQUAL, fail); 1739 __ j(NOT_EQUAL, fail);
1740 } else { 1740 } else {
1741 __ j(EQUAL, &ok); 1741 __ j(EQUAL, &ok);
1742 } 1742 }
1743 } else { 1743 } else {
1744 // Both value's and field's class id is known. 1744 // Both value's and field's class id is known.
1745 if ((value_cid != field_cid) && (value_cid != nullability)) { 1745 if ((value_cid != field_cid) && (value_cid != nullability)) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 // (or null). 2004 // (or null).
2005 ASSERT(!type_arguments().IsUninstantiatedIdentity() && 2005 ASSERT(!type_arguments().IsUninstantiatedIdentity() &&
2006 !type_arguments().CanShareInstantiatorTypeArguments( 2006 !type_arguments().CanShareInstantiatorTypeArguments(
2007 instantiator_class())); 2007 instantiator_class()));
2008 // If the instantiator is null and if the type argument vector 2008 // If the instantiator is null and if the type argument vector
2009 // instantiated from null becomes a vector of dynamic, then use null as 2009 // instantiated from null becomes a vector of dynamic, then use null as
2010 // the type arguments. 2010 // the type arguments.
2011 Label type_arguments_instantiated; 2011 Label type_arguments_instantiated;
2012 const intptr_t len = type_arguments().Length(); 2012 const intptr_t len = type_arguments().Length();
2013 if (type_arguments().IsRawInstantiatedRaw(len)) { 2013 if (type_arguments().IsRawInstantiatedRaw(len)) {
2014 __ CompareObject(instantiator_reg, Object::Handle()); 2014 __ CompareObject(instantiator_reg, Object::null_object());
2015 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); 2015 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump);
2016 } 2016 }
2017 // Instantiate non-null type arguments. 2017 // Instantiate non-null type arguments.
2018 // A runtime call to instantiate the type arguments is required. 2018 // A runtime call to instantiate the type arguments is required.
2019 __ PushObject(Object::ZoneHandle()); // Make room for the result. 2019 __ PushObject(Object::ZoneHandle()); // Make room for the result.
2020 __ PushObject(type_arguments()); 2020 __ PushObject(type_arguments());
2021 __ pushq(instantiator_reg); // Push instantiator type arguments. 2021 __ pushq(instantiator_reg); // Push instantiator type arguments.
2022 compiler->GenerateCallRuntime(token_pos(), 2022 compiler->GenerateCallRuntime(token_pos(),
2023 deopt_id(), 2023 deopt_id(),
2024 kInstantiateTypeArgumentsRuntimeEntry, 2024 kInstantiateTypeArgumentsRuntimeEntry,
(...skipping 28 matching lines...) Expand all
2053 // AbstractTypeArguments object (or null). 2053 // AbstractTypeArguments object (or null).
2054 ASSERT(!type_arguments().IsUninstantiatedIdentity() && 2054 ASSERT(!type_arguments().IsUninstantiatedIdentity() &&
2055 !type_arguments().CanShareInstantiatorTypeArguments( 2055 !type_arguments().CanShareInstantiatorTypeArguments(
2056 instantiator_class())); 2056 instantiator_class()));
2057 // If the instantiator is null and if the type argument vector 2057 // If the instantiator is null and if the type argument vector
2058 // instantiated from null becomes a vector of dynamic, then use null as 2058 // instantiated from null becomes a vector of dynamic, then use null as
2059 // the type arguments. 2059 // the type arguments.
2060 Label type_arguments_instantiated; 2060 Label type_arguments_instantiated;
2061 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); 2061 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length()));
2062 2062
2063 __ CompareObject(instantiator_reg, Object::Handle()); 2063 __ CompareObject(instantiator_reg, Object::null_object());
2064 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); 2064 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump);
2065 // Instantiate non-null type arguments. 2065 // Instantiate non-null type arguments.
2066 // In the non-factory case, we rely on the allocation stub to 2066 // In the non-factory case, we rely on the allocation stub to
2067 // instantiate the type arguments. 2067 // instantiate the type arguments.
2068 __ LoadObject(result_reg, type_arguments(), PP); 2068 __ LoadObject(result_reg, type_arguments(), PP);
2069 // result_reg: uninstantiated type arguments. 2069 // result_reg: uninstantiated type arguments.
2070 2070
2071 __ Bind(&type_arguments_instantiated); 2071 __ Bind(&type_arguments_instantiated);
2072 // result_reg: uninstantiated or instantiated type arguments. 2072 // result_reg: uninstantiated or instantiated type arguments.
2073 } 2073 }
(...skipping 21 matching lines...) Expand all
2095 ASSERT(!type_arguments().IsUninstantiatedIdentity() && 2095 ASSERT(!type_arguments().IsUninstantiatedIdentity() &&
2096 !type_arguments().CanShareInstantiatorTypeArguments( 2096 !type_arguments().CanShareInstantiatorTypeArguments(
2097 instantiator_class())); 2097 instantiator_class()));
2098 2098
2099 // If the instantiator is null and if the type argument vector 2099 // If the instantiator is null and if the type argument vector
2100 // instantiated from null becomes a vector of dynamic, then use null as 2100 // instantiated from null becomes a vector of dynamic, then use null as
2101 // the type arguments and do not pass the instantiator. 2101 // the type arguments and do not pass the instantiator.
2102 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length())); 2102 ASSERT(type_arguments().IsRawInstantiatedRaw(type_arguments().Length()));
2103 2103
2104 Label instantiator_not_null; 2104 Label instantiator_not_null;
2105 __ CompareObject(instantiator_reg, Object::Handle()); 2105 __ CompareObject(instantiator_reg, Object::null_object());
2106 __ j(NOT_EQUAL, &instantiator_not_null, Assembler::kNearJump); 2106 __ j(NOT_EQUAL, &instantiator_not_null, Assembler::kNearJump);
2107 // Null was used in VisitExtractConstructorTypeArguments as the 2107 // Null was used in VisitExtractConstructorTypeArguments as the
2108 // instantiated type arguments, no proper instantiator needed. 2108 // instantiated type arguments, no proper instantiator needed.
2109 __ movq(instantiator_reg, 2109 __ movq(instantiator_reg,
2110 Immediate(Smi::RawValue(StubCode::kNoInstantiator))); 2110 Immediate(Smi::RawValue(StubCode::kNoInstantiator)));
2111 __ Bind(&instantiator_not_null); 2111 __ Bind(&instantiator_not_null);
2112 // instantiator_reg: instantiator or kNoInstantiator. 2112 // instantiator_reg: instantiator or kNoInstantiator.
2113 } 2113 }
2114 2114
2115 2115
(...skipping 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after
4324 } 4324 }
4325 return summary; 4325 return summary;
4326 } 4326 }
4327 4327
4328 4328
4329 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4329 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4330 if (IsNullCheck()) { 4330 if (IsNullCheck()) {
4331 Label* deopt = compiler->AddDeoptStub(deopt_id(), 4331 Label* deopt = compiler->AddDeoptStub(deopt_id(),
4332 kDeoptCheckClass); 4332 kDeoptCheckClass);
4333 __ CompareObject(locs()->in(0).reg(), 4333 __ CompareObject(locs()->in(0).reg(),
4334 Object::Handle()); 4334 Object::null_object());
4335 __ j(EQUAL, deopt); 4335 __ j(EQUAL, deopt);
4336 return; 4336 return;
4337 } 4337 }
4338 4338
4339 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || 4339 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) ||
4340 (unary_checks().NumberOfChecks() > 1)); 4340 (unary_checks().NumberOfChecks() > 1));
4341 Register value = locs()->in(0).reg(); 4341 Register value = locs()->in(0).reg();
4342 Register temp = locs()->temp(0).reg(); 4342 Register temp = locs()->temp(0).reg();
4343 Label* deopt = compiler->AddDeoptStub(deopt_id(), 4343 Label* deopt = compiler->AddDeoptStub(deopt_id(),
4344 kDeoptCheckClass); 4344 kDeoptCheckClass);
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
4836 PcDescriptors::kOther, 4836 PcDescriptors::kOther,
4837 locs()); 4837 locs());
4838 __ Drop(2); // Discard type arguments and receiver. 4838 __ Drop(2); // Discard type arguments and receiver.
4839 } 4839 }
4840 4840
4841 } // namespace dart 4841 } // namespace dart
4842 4842
4843 #undef __ 4843 #undef __
4844 4844
4845 #endif // defined TARGET_ARCH_X64 4845 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698