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

Side by Side Diff: src/hydrogen.cc

Issue 21014004: Add equality type parameter to HCompareObjectAndBranch (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 } 1149 }
1150 1150
1151 if (!IsSimpleMapChangeTransition(from_kind, to_kind)) { 1151 if (!IsSimpleMapChangeTransition(from_kind, to_kind)) {
1152 HInstruction* elements = AddLoadElements(object); 1152 HInstruction* elements = AddLoadElements(object);
1153 1153
1154 HInstruction* empty_fixed_array = Add<HConstant>( 1154 HInstruction* empty_fixed_array = Add<HConstant>(
1155 isolate()->factory()->empty_fixed_array(), Representation::Tagged()); 1155 isolate()->factory()->empty_fixed_array(), Representation::Tagged());
1156 1156
1157 IfBuilder if_builder(this); 1157 IfBuilder if_builder(this);
1158 1158
1159 if_builder.IfNot<HCompareObjectEqAndBranch>(elements, empty_fixed_array); 1159 if_builder.IfNot<HCompareObjectAndBranch>(elements, empty_fixed_array);
1160 1160
1161 if_builder.Then(); 1161 if_builder.Then();
1162 1162
1163 HInstruction* elements_length = AddLoadFixedArrayLength(elements); 1163 HInstruction* elements_length = AddLoadFixedArrayLength(elements);
1164 1164
1165 HInstruction* array_length = is_jsarray 1165 HInstruction* array_length = is_jsarray
1166 ? AddLoad(object, HObjectAccess::ForArrayLength(from_kind), NULL) 1166 ? AddLoad(object, HObjectAccess::ForArrayLength(from_kind), NULL)
1167 : elements_length; 1167 : elements_length;
1168 1168
1169 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, 1169 BuildGrowElementsCapacity(object, elements, from_kind, to_kind,
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 1733
1734 void HGraphBuilder::BuildCompareNil( 1734 void HGraphBuilder::BuildCompareNil(
1735 HValue* value, 1735 HValue* value,
1736 Handle<Type> type, 1736 Handle<Type> type,
1737 int position, 1737 int position,
1738 HIfContinuation* continuation) { 1738 HIfContinuation* continuation) {
1739 IfBuilder if_nil(this, position); 1739 IfBuilder if_nil(this, position);
1740 bool needs_or = false; 1740 bool needs_or = false;
1741 if (type->Maybe(Type::Null())) { 1741 if (type->Maybe(Type::Null())) {
1742 if (needs_or) if_nil.Or(); 1742 if (needs_or) if_nil.Or();
1743 if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); 1743 if_nil.If<HCompareObjectAndBranch>(value, graph()->GetConstantNull());
1744 needs_or = true; 1744 needs_or = true;
1745 } 1745 }
1746 if (type->Maybe(Type::Undefined())) { 1746 if (type->Maybe(Type::Undefined())) {
1747 if (needs_or) if_nil.Or(); 1747 if (needs_or) if_nil.Or();
1748 if_nil.If<HCompareObjectEqAndBranch>(value, 1748 if_nil.If<HCompareObjectAndBranch>(value,
1749 graph()->GetConstantUndefined()); 1749 graph()->GetConstantUndefined());
1750 needs_or = true; 1750 needs_or = true;
1751 } 1751 }
1752 if (type->Maybe(Type::Undetectable())) { 1752 if (type->Maybe(Type::Undetectable())) {
1753 if (needs_or) if_nil.Or(); 1753 if (needs_or) if_nil.Or();
1754 if_nil.If<HIsUndetectableAndBranch>(value); 1754 if_nil.If<HIsUndetectableAndBranch>(value);
1755 } else { 1755 } else {
1756 if_nil.Then(); 1756 if_nil.Then();
1757 if_nil.Else(); 1757 if_nil.Else();
1758 if (type->NumClasses() == 1) { 1758 if (type->NumClasses() == 1) {
1759 BuildCheckHeapObject(value); 1759 BuildCheckHeapObject(value);
(...skipping 3176 matching lines...) Expand 10 before | Expand all | Expand 10 after
4936 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, true); 4936 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, true);
4937 if (type == kUseCell) { 4937 if (type == kUseCell) {
4938 Handle<GlobalObject> global(current_info()->global_object()); 4938 Handle<GlobalObject> global(current_info()->global_object());
4939 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); 4939 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
4940 if (cell->type()->IsConstant()) { 4940 if (cell->type()->IsConstant()) {
4941 IfBuilder builder(this); 4941 IfBuilder builder(this);
4942 HValue* constant = Add<HConstant>(cell->type()->AsConstant()); 4942 HValue* constant = Add<HConstant>(cell->type()->AsConstant());
4943 if (cell->type()->AsConstant()->IsNumber()) { 4943 if (cell->type()->AsConstant()->IsNumber()) {
4944 builder.If<HCompareNumericAndBranch>(value, constant, Token::EQ); 4944 builder.If<HCompareNumericAndBranch>(value, constant, Token::EQ);
4945 } else { 4945 } else {
4946 builder.If<HCompareObjectEqAndBranch>(value, constant); 4946 builder.If<HCompareObjectAndBranch>(value, constant);
4947 } 4947 }
4948 builder.Then(); 4948 builder.Then();
4949 builder.Else(); 4949 builder.Else();
4950 Add<HDeoptimize>(Deoptimizer::EAGER); 4950 Add<HDeoptimize>(Deoptimizer::EAGER);
4951 builder.End(); 4951 builder.End();
4952 } 4952 }
4953 HInstruction* instr = 4953 HInstruction* instr =
4954 Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails()); 4954 Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails());
4955 instr->set_position(position); 4955 instr->set_position(position);
4956 if (instr->HasObservableSideEffects()) { 4956 if (instr->HasObservableSideEffects()) {
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after
7784 Representation rep = Representation::FromType(expected_type); 7784 Representation rep = Representation::FromType(expected_type);
7785 if (!rep.IsTagged()) return value; 7785 if (!rep.IsTagged()) return value;
7786 7786
7787 // If our type feedback suggests that we can non-observably truncate to number 7787 // If our type feedback suggests that we can non-observably truncate to number
7788 // we introduce the appropriate check here. This avoids 'value' having a 7788 // we introduce the appropriate check here. This avoids 'value' having a
7789 // tagged representation later on. 7789 // tagged representation later on.
7790 if (expected_type->Is(Type::Oddball())) { 7790 if (expected_type->Is(Type::Oddball())) {
7791 // TODO(olivf) The BinaryOpStub only records undefined. It might pay off to 7791 // TODO(olivf) The BinaryOpStub only records undefined. It might pay off to
7792 // also record booleans and convert them to 0/1 here. 7792 // also record booleans and convert them to 0/1 here.
7793 IfBuilder if_nan(this); 7793 IfBuilder if_nan(this);
7794 if_nan.If<HCompareObjectEqAndBranch>(value, 7794 if_nan.If<HCompareObjectAndBranch>(value,
7795 graph()->GetConstantUndefined()); 7795 graph()->GetConstantUndefined());
7796 if_nan.Then(); 7796 if_nan.Then();
7797 if_nan.ElseDeopt(); 7797 if_nan.ElseDeopt();
7798 if_nan.End(); 7798 if_nan.End();
7799 return Add<HConstant>(OS::nan_value(), Representation::Double()); 7799 return Add<HConstant>(OS::nan_value(), Representation::Double());
7800 } 7800 }
7801 7801
7802 return value; 7802 return value;
7803 } 7803 }
7804 7804
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
8113 8113
8114 CHECK_ALIVE(VisitForValue(expr->left())); 8114 CHECK_ALIVE(VisitForValue(expr->left()));
8115 CHECK_ALIVE(VisitForValue(expr->right())); 8115 CHECK_ALIVE(VisitForValue(expr->right()));
8116 8116
8117 HValue* context = environment()->LookupContext(); 8117 HValue* context = environment()->LookupContext();
8118 HValue* right = Pop(); 8118 HValue* right = Pop();
8119 HValue* left = Pop(); 8119 HValue* left = Pop();
8120 Token::Value op = expr->op(); 8120 Token::Value op = expr->op();
8121 8121
8122 if (IsLiteralCompareBool(left, op, right)) { 8122 if (IsLiteralCompareBool(left, op, right)) {
8123 HCompareObjectEqAndBranch* result = 8123 HCompareObjectAndBranch* result =
8124 new(zone()) HCompareObjectEqAndBranch(left, right); 8124 new(zone()) HCompareObjectAndBranch(left, right);
8125 result->set_position(expr->position()); 8125 result->set_position(expr->position());
8126 return ast_context()->ReturnControl(result, expr->id()); 8126 return ast_context()->ReturnControl(result, expr->id());
8127 } 8127 }
8128 8128
8129 if (op == Token::INSTANCEOF) { 8129 if (op == Token::INSTANCEOF) {
8130 // Check to see if the rhs of the instanceof is a global function not 8130 // Check to see if the rhs of the instanceof is a global function not
8131 // residing in new space. If it is we assume that the function will stay the 8131 // residing in new space. If it is we assume that the function will stay the
8132 // same. 8132 // same.
8133 Handle<JSFunction> target = Handle<JSFunction>::null(); 8133 Handle<JSFunction> target = Handle<JSFunction>::null();
8134 VariableProxy* proxy = expr->right()->AsVariableProxy(); 8134 VariableProxy* proxy = expr->right()->AsVariableProxy();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
8186 8186
8187 if (combined_type->Is(Type::Receiver())) { 8187 if (combined_type->Is(Type::Receiver())) {
8188 switch (op) { 8188 switch (op) {
8189 case Token::EQ: 8189 case Token::EQ:
8190 case Token::EQ_STRICT: { 8190 case Token::EQ_STRICT: {
8191 // Can we get away with map check and not instance type check? 8191 // Can we get away with map check and not instance type check?
8192 if (combined_type->IsClass()) { 8192 if (combined_type->IsClass()) {
8193 Handle<Map> map = combined_type->AsClass(); 8193 Handle<Map> map = combined_type->AsClass();
8194 AddCheckMapsWithTransitions(left, map); 8194 AddCheckMapsWithTransitions(left, map);
8195 AddCheckMapsWithTransitions(right, map); 8195 AddCheckMapsWithTransitions(right, map);
8196 HCompareObjectEqAndBranch* result = 8196 HCompareObjectAndBranch* result =
8197 new(zone()) HCompareObjectEqAndBranch(left, right); 8197 new(zone()) HCompareObjectAndBranch(left, right);
8198 result->set_position(expr->position()); 8198 result->set_position(expr->position());
8199 return ast_context()->ReturnControl(result, expr->id()); 8199 return ast_context()->ReturnControl(result, expr->id());
8200 } else { 8200 } else {
8201 BuildCheckHeapObject(left); 8201 BuildCheckHeapObject(left);
8202 AddInstruction(HCheckInstanceType::NewIsSpecObject(left, zone())); 8202 AddInstruction(HCheckInstanceType::NewIsSpecObject(left, zone()));
8203 BuildCheckHeapObject(right); 8203 BuildCheckHeapObject(right);
8204 AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone())); 8204 AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone()));
8205 HCompareObjectEqAndBranch* result = 8205 HCompareObjectAndBranch* result =
8206 new(zone()) HCompareObjectEqAndBranch(left, right); 8206 new(zone()) HCompareObjectAndBranch(left, right);
8207 result->set_position(expr->position()); 8207 result->set_position(expr->position());
8208 return ast_context()->ReturnControl(result, expr->id()); 8208 return ast_context()->ReturnControl(result, expr->id());
8209 } 8209 }
8210 } 8210 }
8211 default: 8211 default:
8212 return Bailout("Unsupported non-primitive compare"); 8212 return Bailout("Unsupported non-primitive compare");
8213 } 8213 }
8214 } else if (combined_type->Is(Type::InternalizedString()) && 8214 } else if (combined_type->Is(Type::InternalizedString()) &&
8215 Token::IsEqualityOp(op)) { 8215 Token::IsEqualityOp(op)) {
8216 BuildCheckHeapObject(left); 8216 BuildCheckHeapObject(left);
8217 AddInstruction(HCheckInstanceType::NewIsInternalizedString(left, zone())); 8217 AddInstruction(HCheckInstanceType::NewIsInternalizedString(left, zone()));
8218 BuildCheckHeapObject(right); 8218 BuildCheckHeapObject(right);
8219 AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone())); 8219 AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone()));
8220 HCompareObjectEqAndBranch* result = 8220 HCompareObjectAndBranch* result =
8221 new(zone()) HCompareObjectEqAndBranch(left, right); 8221 new(zone()) HCompareObjectAndBranch(left, right);
8222 result->set_position(expr->position()); 8222 result->set_position(expr->position());
8223 return ast_context()->ReturnControl(result, expr->id()); 8223 return ast_context()->ReturnControl(result, expr->id());
8224 } else { 8224 } else {
8225 if (combined_rep.IsTagged() || combined_rep.IsNone()) { 8225 if (combined_rep.IsTagged() || combined_rep.IsNone()) {
8226 HCompareGeneric* result = 8226 HCompareGeneric* result =
8227 new(zone()) HCompareGeneric(context, left, right, op); 8227 new(zone()) HCompareGeneric(context, left, right, op);
8228 result->set_observed_input_representation(1, left_rep); 8228 result->set_observed_input_representation(1, left_rep);
8229 result->set_observed_input_representation(2, right_rep); 8229 result->set_observed_input_representation(2, right_rep);
8230 result->set_position(expr->position()); 8230 result->set_position(expr->position());
8231 return ast_context()->ReturnInstruction(result, expr->id()); 8231 return ast_context()->ReturnInstruction(result, expr->id());
(...skipping 17 matching lines...) Expand all
8249 NilValue nil) { 8249 NilValue nil) {
8250 ASSERT(!HasStackOverflow()); 8250 ASSERT(!HasStackOverflow());
8251 ASSERT(current_block() != NULL); 8251 ASSERT(current_block() != NULL);
8252 ASSERT(current_block()->HasPredecessor()); 8252 ASSERT(current_block()->HasPredecessor());
8253 ASSERT(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT); 8253 ASSERT(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT);
8254 CHECK_ALIVE(VisitForValue(sub_expr)); 8254 CHECK_ALIVE(VisitForValue(sub_expr));
8255 HValue* value = Pop(); 8255 HValue* value = Pop();
8256 HIfContinuation continuation; 8256 HIfContinuation continuation;
8257 if (expr->op() == Token::EQ_STRICT) { 8257 if (expr->op() == Token::EQ_STRICT) {
8258 IfBuilder if_nil(this); 8258 IfBuilder if_nil(this);
8259 if_nil.If<HCompareObjectEqAndBranch>( 8259 if_nil.If<HCompareObjectAndBranch>(
8260 value, (nil == kNullValue) ? graph()->GetConstantNull() 8260 value, (nil == kNullValue) ? graph()->GetConstantNull()
8261 : graph()->GetConstantUndefined()); 8261 : graph()->GetConstantUndefined());
8262 if_nil.Then(); 8262 if_nil.Then();
8263 if_nil.Else(); 8263 if_nil.Else();
8264 if_nil.CaptureContinuation(&continuation); 8264 if_nil.CaptureContinuation(&continuation);
8265 return ast_context()->ReturnContinuation(&continuation, expr->id()); 8265 return ast_context()->ReturnContinuation(&continuation, expr->id());
8266 } 8266 }
8267 Handle<Type> type = expr->combined_type()->Is(Type::None()) 8267 Handle<Type> type = expr->combined_type()->Is(Type::None())
8268 ? handle(Type::Any(), isolate_) : expr->combined_type(); 8268 ? handle(Type::Any(), isolate_) : expr->combined_type();
8269 BuildCompareNil(value, type, expr->position(), &continuation); 8269 BuildCompareNil(value, type, expr->position(), &continuation);
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
9046 } 9046 }
9047 9047
9048 9048
9049 // Fast support for object equality testing. 9049 // Fast support for object equality testing.
9050 void HOptimizedGraphBuilder::GenerateObjectEquals(CallRuntime* call) { 9050 void HOptimizedGraphBuilder::GenerateObjectEquals(CallRuntime* call) {
9051 ASSERT(call->arguments()->length() == 2); 9051 ASSERT(call->arguments()->length() == 2);
9052 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9052 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9053 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9053 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9054 HValue* right = Pop(); 9054 HValue* right = Pop();
9055 HValue* left = Pop(); 9055 HValue* left = Pop();
9056 HCompareObjectEqAndBranch* result = 9056 HCompareObjectAndBranch* result =
9057 new(zone()) HCompareObjectEqAndBranch(left, right); 9057 new(zone()) HCompareObjectAndBranch(left, right);
9058 return ast_context()->ReturnControl(result, call->id()); 9058 return ast_context()->ReturnControl(result, call->id());
9059 } 9059 }
9060 9060
9061 9061
9062 void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) { 9062 void HOptimizedGraphBuilder::GenerateLog(CallRuntime* call) {
9063 // %_Log is ignored in optimized code. 9063 // %_Log is ignored in optimized code.
9064 return ast_context()->ReturnValue(graph()->GetConstantUndefined()); 9064 return ast_context()->ReturnValue(graph()->GetConstantUndefined());
9065 } 9065 }
9066 9066
9067 9067
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
9912 if (ShouldProduceTraceOutput()) { 9912 if (ShouldProduceTraceOutput()) {
9913 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9913 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9914 } 9914 }
9915 9915
9916 #ifdef DEBUG 9916 #ifdef DEBUG
9917 graph_->Verify(false); // No full verify. 9917 graph_->Verify(false); // No full verify.
9918 #endif 9918 #endif
9919 } 9919 }
9920 9920
9921 } } // namespace v8::internal 9921 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698