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( |
| 1277 HValue* object, const char* failure_reason) { |
| 1278 if (!object->type().IsString()) { |
| 1279 ASSERT(!object->IsConstant() || |
| 1280 !HConstant::cast(object)->HasStringValue()); |
| 1281 IfBuilder if_isstring(this); |
| 1282 if_isstring.If<HIsStringAndBranch>(object); |
| 1283 if_isstring.Then(); |
| 1284 if_isstring.ElseDeopt(failure_reason); |
| 1285 } |
| 1286 return object; |
| 1287 } |
| 1288 |
| 1289 |
1276 HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { | 1290 HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { |
1277 if (object->type().IsJSObject()) return object; | 1291 if (object->type().IsJSObject()) return object; |
1278 return Add<HWrapReceiver>(object, function); | 1292 return Add<HWrapReceiver>(object, function); |
1279 } | 1293 } |
1280 | 1294 |
1281 | 1295 |
1282 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, | 1296 HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, |
1283 HValue* elements, | 1297 HValue* elements, |
1284 ElementsKind kind, | 1298 ElementsKind kind, |
1285 HValue* length, | 1299 HValue* length, |
(...skipping 7338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8624 } else { | 8638 } else { |
8625 if (!maybe_string_add) right = TruncateToNumber(right, &right_type); | 8639 if (!maybe_string_add) right = TruncateToNumber(right, &right_type); |
8626 right_rep = Representation::FromType(right_type); | 8640 right_rep = Representation::FromType(right_type); |
8627 } | 8641 } |
8628 | 8642 |
8629 // Special case for string addition here. | 8643 // Special case for string addition here. |
8630 if (op == Token::ADD && | 8644 if (op == Token::ADD && |
8631 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { | 8645 (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { |
8632 // Validate type feedback for left argument. | 8646 // Validate type feedback for left argument. |
8633 if (left_type->Is(Type::String())) { | 8647 if (left_type->Is(Type::String())) { |
8634 IfBuilder if_isstring(this); | 8648 left = BuildCheckString( |
8635 if_isstring.If<HIsStringAndBranch>(left); | 8649 left, "Expected string for LHS of binary operation"); |
8636 if_isstring.Then(); | |
8637 if_isstring.ElseDeopt("Expected string for LHS of binary operation"); | |
8638 } | 8650 } |
8639 | 8651 |
8640 // Validate type feedback for right argument. | 8652 // Validate type feedback for right argument. |
8641 if (right_type->Is(Type::String())) { | 8653 if (right_type->Is(Type::String())) { |
8642 IfBuilder if_isstring(this); | 8654 right = BuildCheckString( |
8643 if_isstring.If<HIsStringAndBranch>(right); | 8655 right, "Expected string for RHS of binary operation"); |
8644 if_isstring.Then(); | |
8645 if_isstring.ElseDeopt("Expected string for RHS of binary operation"); | |
8646 } | 8656 } |
8647 | 8657 |
8648 // Convert left argument as necessary. | 8658 // Convert left argument as necessary. |
8649 if (left_type->Is(Type::Number())) { | 8659 if (left_type->Is(Type::Number())) { |
8650 ASSERT(right_type->Is(Type::String())); | 8660 ASSERT(right_type->Is(Type::String())); |
8651 left = BuildNumberToString(left, left_type); | 8661 left = BuildNumberToString(left, left_type); |
8652 } else if (!left_type->Is(Type::String())) { | 8662 } else if (!left_type->Is(Type::String())) { |
8653 ASSERT(right_type->Is(Type::String())); | 8663 ASSERT(right_type->Is(Type::String())); |
8654 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); | 8664 HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); |
8655 Add<HPushArgument>(left); | 8665 Add<HPushArgument>(left); |
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10633 if (ShouldProduceTraceOutput()) { | 10643 if (ShouldProduceTraceOutput()) { |
10634 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10644 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10635 } | 10645 } |
10636 | 10646 |
10637 #ifdef DEBUG | 10647 #ifdef DEBUG |
10638 graph_->Verify(false); // No full verify. | 10648 graph_->Verify(false); // No full verify. |
10639 #endif | 10649 #endif |
10640 } | 10650 } |
10641 | 10651 |
10642 } } // namespace v8::internal | 10652 } } // namespace v8::internal |
OLD | NEW |