OLD | NEW |
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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 ASSERT(continuation->predecessors()->length() == 0); | 1266 ASSERT(continuation->predecessors()->length() == 0); |
1267 } | 1267 } |
1268 } | 1268 } |
1269 | 1269 |
1270 | 1270 |
1271 HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) { | 1271 HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) { |
1272 return Add<HCheckMaps>(obj, map, top_info()); | 1272 return Add<HCheckMaps>(obj, map, top_info()); |
1273 } | 1273 } |
1274 | 1274 |
1275 | 1275 |
1276 HValue* HGraphBuilder::BuildCheckString( | 1276 HValue* HGraphBuilder::BuildCheckString(HValue* string) { |
1277 HValue* object, const char* failure_reason) { | 1277 if (!string->type().IsString()) { |
1278 if (!object->type().IsString()) { | 1278 ASSERT(!string->IsConstant() || |
1279 ASSERT(!object->IsConstant() || | 1279 !HConstant::cast(string)->HasStringValue()); |
1280 !HConstant::cast(object)->HasStringValue()); | 1280 BuildCheckHeapObject(string); |
1281 IfBuilder if_isstring(this); | 1281 return Add<HCheckInstanceType>(string, HCheckInstanceType::IS_STRING); |
1282 if_isstring.If<HIsStringAndBranch>(object); | |
1283 if_isstring.Then(); | |
1284 if_isstring.ElseDeopt(failure_reason); | |
1285 } | 1282 } |
1286 return object; | 1283 return string; |
1287 } | 1284 } |
1288 | 1285 |
1289 | 1286 |
1290 HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { | 1287 HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { |
1291 if (object->type().IsJSObject()) return object; | 1288 if (object->type().IsJSObject()) return object; |
1292 return Add<HWrapReceiver>(object, function); | 1289 return Add<HWrapReceiver>(object, function); |
1293 } | 1290 } |
1294 | 1291 |
1295 | 1292 |
1296 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, | 1293 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, |
(...skipping 7343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8640 } else { | 8637 } else { |
8641 if (!maybe_string_add) right = TruncateToNumber(right, &right_type); | 8638 if (!maybe_string_add) right = TruncateToNumber(right, &right_type); |
8642 right_rep = Representation::FromType(right_type); | 8639 right_rep = Representation::FromType(right_type); |
8643 } | 8640 } |
8644 | 8641 |
8645 // Special case for string addition here. | 8642 // Special case for string addition here. |
8646 if (op == Token::ADD && | 8643 if (op == Token::ADD && |
8647 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { | 8644 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { |
8648 // Validate type feedback for left argument. | 8645 // Validate type feedback for left argument. |
8649 if (left_type->Is(Type::String())) { | 8646 if (left_type->Is(Type::String())) { |
8650 left = BuildCheckString( | 8647 left = BuildCheckString(left); |
8651 left, "Expected string for LHS of binary operation"); | |
8652 } | 8648 } |
8653 | 8649 |
8654 // Validate type feedback for right argument. | 8650 // Validate type feedback for right argument. |
8655 if (right_type->Is(Type::String())) { | 8651 if (right_type->Is(Type::String())) { |
8656 right = BuildCheckString( | 8652 right = BuildCheckString(right); |
8657 right, "Expected string for RHS of binary operation"); | |
8658 } | 8653 } |
8659 | 8654 |
8660 // Convert left argument as necessary. | 8655 // Convert left argument as necessary. |
8661 if (left_type->Is(Type::Number())) { | 8656 if (left_type->Is(Type::Number())) { |
8662 ASSERT(right_type->Is(Type::String())); | 8657 ASSERT(right_type->Is(Type::String())); |
8663 left = BuildNumberToString(left, left_type); | 8658 left = BuildNumberToString(left, left_type); |
8664 } else if (!left_type->Is(Type::String())) { | 8659 } else if (!left_type->Is(Type::String())) { |
8665 ASSERT(right_type->Is(Type::String())); | 8660 ASSERT(right_type->Is(Type::String())); |
8666 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); | 8661 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); |
8667 Add<HPushArgument>(left); | 8662 Add<HPushArgument>(left); |
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10652 if (ShouldProduceTraceOutput()) { | 10647 if (ShouldProduceTraceOutput()) { |
10653 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10648 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10654 } | 10649 } |
10655 | 10650 |
10656 #ifdef DEBUG | 10651 #ifdef DEBUG |
10657 graph_->Verify(false); // No full verify. | 10652 graph_->Verify(false); // No full verify. |
10658 #endif | 10653 #endif |
10659 } | 10654 } |
10660 | 10655 |
10661 } } // namespace v8::internal | 10656 } } // namespace v8::internal |
OLD | NEW |