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

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 1681813004: Drop null/undefined check if we already check for IsUndetectable in BuildCompareNil (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor cleanup Created 4 years, 10 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
« no previous file with comments | « src/code-stubs.cc ('k') | src/ic/ic.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/crankshaft/hydrogen.h" 5 #include "src/crankshaft/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/allocation-site-scopes.h" 9 #include "src/allocation-site-scopes.h"
10 #include "src/ast/ast-numbering.h" 10 #include "src/ast/ast-numbering.h"
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 680
681 HConstant* HGraph::GetConstantMinus1() { 681 HConstant* HGraph::GetConstantMinus1() {
682 return GetConstant(&constant_minus1_, -1); 682 return GetConstant(&constant_minus1_, -1);
683 } 683 }
684 684
685 685
686 HConstant* HGraph::GetConstantBool(bool value) { 686 HConstant* HGraph::GetConstantBool(bool value) {
687 return value ? GetConstantTrue() : GetConstantFalse(); 687 return value ? GetConstantTrue() : GetConstantFalse();
688 } 688 }
689 689
690 #define DEFINE_GET_CONSTANT(Name, name, type, htype, boolean_value, \
691 undetectable) \
692 HConstant* HGraph::GetConstant##Name() { \
693 if (!constant_##name##_.is_set()) { \
694 HConstant* constant = new (zone()) HConstant( \
695 Unique<Object>::CreateImmovable( \
696 isolate()->factory()->name##_value()), \
697 Unique<Map>::CreateImmovable(isolate()->factory()->type##_map()), \
698 false, Representation::Tagged(), htype, true, boolean_value, \
699 undetectable, ODDBALL_TYPE); \
700 constant->InsertAfter(entry_block()->first()); \
701 constant_##name##_.set(constant); \
702 } \
703 return ReinsertConstantIfNecessary(constant_##name##_.get()); \
704 }
690 705
691 #define DEFINE_GET_CONSTANT(Name, name, type, htype, boolean_value) \ 706 DEFINE_GET_CONSTANT(Undefined, undefined, undefined, HType::Undefined(), false,
692 HConstant* HGraph::GetConstant##Name() { \ 707 true)
693 if (!constant_##name##_.is_set()) { \ 708 DEFINE_GET_CONSTANT(True, true, boolean, HType::Boolean(), true, false)
694 HConstant* constant = new(zone()) HConstant( \ 709 DEFINE_GET_CONSTANT(False, false, boolean, HType::Boolean(), false, false)
695 Unique<Object>::CreateImmovable(isolate()->factory()->name##_value()), \ 710 DEFINE_GET_CONSTANT(Hole, the_hole, the_hole, HType::None(), false, false)
696 Unique<Map>::CreateImmovable(isolate()->factory()->type##_map()), \ 711 DEFINE_GET_CONSTANT(Null, null, null, HType::Null(), false, true)
697 false, \
698 Representation::Tagged(), \
699 htype, \
700 true, \
701 boolean_value, \
702 false, \
703 ODDBALL_TYPE); \
704 constant->InsertAfter(entry_block()->first()); \
705 constant_##name##_.set(constant); \
706 } \
707 return ReinsertConstantIfNecessary(constant_##name##_.get()); \
708 }
709
710
711 DEFINE_GET_CONSTANT(Undefined, undefined, undefined, HType::Undefined(), false)
712 DEFINE_GET_CONSTANT(True, true, boolean, HType::Boolean(), true)
713 DEFINE_GET_CONSTANT(False, false, boolean, HType::Boolean(), false)
714 DEFINE_GET_CONSTANT(Hole, the_hole, the_hole, HType::None(), false)
715 DEFINE_GET_CONSTANT(Null, null, null, HType::Null(), false)
716
717 712
718 #undef DEFINE_GET_CONSTANT 713 #undef DEFINE_GET_CONSTANT
719 714
720 #define DEFINE_IS_CONSTANT(Name, name) \ 715 #define DEFINE_IS_CONSTANT(Name, name) \
721 bool HGraph::IsConstant##Name(HConstant* constant) { \ 716 bool HGraph::IsConstant##Name(HConstant* constant) { \
722 return constant_##name##_.is_set() && constant == constant_##name##_.get(); \ 717 return constant_##name##_.is_set() && constant == constant_##name##_.get(); \
723 } 718 }
724 DEFINE_IS_CONSTANT(Undefined, undefined) 719 DEFINE_IS_CONSTANT(Undefined, undefined)
725 DEFINE_IS_CONSTANT(0, 0) 720 DEFINE_IS_CONSTANT(0, 0)
726 DEFINE_IS_CONSTANT(1, 1) 721 DEFINE_IS_CONSTANT(1, 1)
(...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after
3172 BuildCopyElements(boilerplate_elements, kind, elements, 3167 BuildCopyElements(boilerplate_elements, kind, elements,
3173 kind, length, NULL); 3168 kind, length, NULL);
3174 return result; 3169 return result;
3175 } 3170 }
3176 3171
3177 3172
3178 void HGraphBuilder::BuildCompareNil(HValue* value, Type* type, 3173 void HGraphBuilder::BuildCompareNil(HValue* value, Type* type,
3179 HIfContinuation* continuation, 3174 HIfContinuation* continuation,
3180 MapEmbedding map_embedding) { 3175 MapEmbedding map_embedding) {
3181 IfBuilder if_nil(this); 3176 IfBuilder if_nil(this);
3182 bool some_case_handled = false;
3183 bool some_case_missing = false;
3184
3185 if (type->Maybe(Type::Null())) {
3186 if (some_case_handled) if_nil.Or();
3187 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull());
3188 some_case_handled = true;
3189 } else {
3190 some_case_missing = true;
3191 }
3192
3193 if (type->Maybe(Type::Undefined())) {
3194 if (some_case_handled) if_nil.Or();
3195 if_nil.If<HCompareObjectEqAndBranch>(value,
3196 graph()->GetConstantUndefined());
3197 some_case_handled = true;
3198 } else {
3199 some_case_missing = true;
3200 }
3201 3177
3202 if (type->Maybe(Type::Undetectable())) { 3178 if (type->Maybe(Type::Undetectable())) {
3203 if (some_case_handled) if_nil.Or();
3204 if_nil.If<HIsUndetectableAndBranch>(value); 3179 if_nil.If<HIsUndetectableAndBranch>(value);
3205 some_case_handled = true;
3206 } else { 3180 } else {
3207 some_case_missing = true; 3181 bool maybe_null = type->Maybe(Type::Null());
3208 } 3182 if (maybe_null) {
3183 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull());
3184 }
3209 3185
3210 if (some_case_missing) { 3186 if (type->Maybe(Type::Undefined())) {
3187 if (maybe_null) if_nil.Or();
3188 if_nil.If<HCompareObjectEqAndBranch>(value,
3189 graph()->GetConstantUndefined());
3190 }
3191
3211 if_nil.Then(); 3192 if_nil.Then();
3212 if_nil.Else(); 3193 if_nil.Else();
3194
3213 if (type->NumClasses() == 1) { 3195 if (type->NumClasses() == 1) {
3214 BuildCheckHeapObject(value); 3196 BuildCheckHeapObject(value);
3215 // For ICs, the map checked below is a sentinel map that gets replaced by 3197 // For ICs, the map checked below is a sentinel map that gets replaced by
3216 // the monomorphic map when the code is used as a template to generate a 3198 // the monomorphic map when the code is used as a template to generate a
3217 // new IC. For optimized functions, there is no sentinel map, the map 3199 // new IC. For optimized functions, there is no sentinel map, the map
3218 // emitted below is the actual monomorphic map. 3200 // emitted below is the actual monomorphic map.
3219 if (map_embedding == kEmbedMapsViaWeakCells) { 3201 if (map_embedding == kEmbedMapsViaWeakCells) {
3220 HValue* cell = 3202 HValue* cell =
3221 Add<HConstant>(Map::WeakCellForMap(type->Classes().Current())); 3203 Add<HConstant>(Map::WeakCellForMap(type->Classes().Current()));
3222 HValue* expected_map = Add<HLoadNamedField>( 3204 HValue* expected_map = Add<HLoadNamedField>(
(...skipping 10425 matching lines...) Expand 10 before | Expand all | Expand 10 after
13648 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13630 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13649 } 13631 }
13650 13632
13651 #ifdef DEBUG 13633 #ifdef DEBUG
13652 graph_->Verify(false); // No full verify. 13634 graph_->Verify(false); // No full verify.
13653 #endif 13635 #endif
13654 } 13636 }
13655 13637
13656 } // namespace internal 13638 } // namespace internal
13657 } // namespace v8 13639 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/ic/ic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698