| OLD | NEW |
| 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 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 Add<HPushArguments>(object); | 2043 Add<HPushArguments>(object); |
| 2044 Push(Add<HCallRuntime>( | 2044 Push(Add<HCallRuntime>( |
| 2045 Runtime::FunctionForId(Runtime::kNumberToStringSkipCache), | 2045 Runtime::FunctionForId(Runtime::kNumberToStringSkipCache), |
| 2046 1)); | 2046 1)); |
| 2047 } | 2047 } |
| 2048 if_found.End(); | 2048 if_found.End(); |
| 2049 | 2049 |
| 2050 return Pop(); | 2050 return Pop(); |
| 2051 } | 2051 } |
| 2052 | 2052 |
| 2053 | 2053 HValue* HGraphBuilder::BuildToNumber(HValue* input) { |
| 2054 HValue* HGraphBuilder::BuildToNumber(HValue* input, Type* input_type) { | 2054 if (input->type().IsTaggedNumber()) { |
| 2055 if (input->type().IsTaggedNumber() || input_type->Is(Type::Number())) { | |
| 2056 return input; | 2055 return input; |
| 2057 } | 2056 } |
| 2058 Callable callable = CodeFactory::ToNumber(isolate()); | 2057 Callable callable = CodeFactory::ToNumber(isolate()); |
| 2059 HValue* stub = Add<HConstant>(callable.code()); | 2058 HValue* stub = Add<HConstant>(callable.code()); |
| 2060 HValue* values[] = {context(), input}; | 2059 HValue* values[] = {context(), input}; |
| 2061 HCallWithDescriptor* instr = | 2060 HCallWithDescriptor* instr = |
| 2062 Add<HCallWithDescriptor>(stub, 0, callable.descriptor(), | 2061 Add<HCallWithDescriptor>(stub, 0, callable.descriptor(), |
| 2063 Vector<HValue*>(values, arraysize(values))); | 2062 Vector<HValue*>(values, arraysize(values))); |
| 2064 instr->set_type(HType::TaggedNumber()); | 2063 instr->set_type(HType::TaggedNumber()); |
| 2065 return instr; | 2064 return instr; |
| (...skipping 9056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11122 | 11121 |
| 11123 // Fallback to using the string add stub. | 11122 // Fallback to using the string add stub. |
| 11124 return AddUncasted<HStringAdd>( | 11123 return AddUncasted<HStringAdd>( |
| 11125 left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CHECK_NONE, | 11124 left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CHECK_NONE, |
| 11126 allocation_mode.feedback_site()); | 11125 allocation_mode.feedback_site()); |
| 11127 } | 11126 } |
| 11128 | 11127 |
| 11129 // Special case for +x here. | 11128 // Special case for +x here. |
| 11130 if (op == Token::MUL) { | 11129 if (op == Token::MUL) { |
| 11131 if (left->EqualsInteger32Constant(1)) { | 11130 if (left->EqualsInteger32Constant(1)) { |
| 11132 return BuildToNumber(right, right_type); | 11131 return BuildToNumber(right); |
| 11133 } | 11132 } |
| 11134 if (right->EqualsInteger32Constant(1)) { | 11133 if (right->EqualsInteger32Constant(1)) { |
| 11135 return BuildToNumber(left, left_type); | 11134 return BuildToNumber(left); |
| 11136 } | 11135 } |
| 11137 } | 11136 } |
| 11138 | 11137 |
| 11139 if (graph()->info()->IsStub()) { | 11138 if (graph()->info()->IsStub()) { |
| 11140 left = EnforceNumberType(left, left_type); | 11139 left = EnforceNumberType(left, left_type); |
| 11141 right = EnforceNumberType(right, right_type); | 11140 right = EnforceNumberType(right, right_type); |
| 11142 } | 11141 } |
| 11143 | 11142 |
| 11144 Representation result_rep = RepresentationFor(result_type); | 11143 Representation result_rep = RepresentationFor(result_type); |
| 11145 | 11144 |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12353 Vector<HValue*>(values, arraysize(values))); | 12352 Vector<HValue*>(values, arraysize(values))); |
| 12354 return ast_context()->ReturnInstruction(result, call->id()); | 12353 return ast_context()->ReturnInstruction(result, call->id()); |
| 12355 } | 12354 } |
| 12356 | 12355 |
| 12357 | 12356 |
| 12358 void HOptimizedGraphBuilder::GenerateToNumber(CallRuntime* call) { | 12357 void HOptimizedGraphBuilder::GenerateToNumber(CallRuntime* call) { |
| 12359 DCHECK_EQ(1, call->arguments()->length()); | 12358 DCHECK_EQ(1, call->arguments()->length()); |
| 12360 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12359 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 12361 Callable callable = CodeFactory::ToNumber(isolate()); | 12360 Callable callable = CodeFactory::ToNumber(isolate()); |
| 12362 HValue* input = Pop(); | 12361 HValue* input = Pop(); |
| 12363 Type* input_type = Type::Any(); | 12362 HValue* result = BuildToNumber(input); |
| 12364 HValue* result = BuildToNumber(input, input_type); | |
| 12365 if (result->HasObservableSideEffects()) { | 12363 if (result->HasObservableSideEffects()) { |
| 12366 if (!ast_context()->IsEffect()) Push(result); | 12364 if (!ast_context()->IsEffect()) Push(result); |
| 12367 Add<HSimulate>(call->id(), REMOVABLE_SIMULATE); | 12365 Add<HSimulate>(call->id(), REMOVABLE_SIMULATE); |
| 12368 if (!ast_context()->IsEffect()) result = Pop(); | 12366 if (!ast_context()->IsEffect()) result = Pop(); |
| 12369 } | 12367 } |
| 12370 return ast_context()->ReturnValue(result); | 12368 return ast_context()->ReturnValue(result); |
| 12371 } | 12369 } |
| 12372 | 12370 |
| 12373 | 12371 |
| 12374 void HOptimizedGraphBuilder::GenerateIsJSProxy(CallRuntime* call) { | 12372 void HOptimizedGraphBuilder::GenerateIsJSProxy(CallRuntime* call) { |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13525 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13523 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13526 } | 13524 } |
| 13527 | 13525 |
| 13528 #ifdef DEBUG | 13526 #ifdef DEBUG |
| 13529 graph_->Verify(false); // No full verify. | 13527 graph_->Verify(false); // No full verify. |
| 13530 #endif | 13528 #endif |
| 13531 } | 13529 } |
| 13532 | 13530 |
| 13533 } // namespace internal | 13531 } // namespace internal |
| 13534 } // namespace v8 | 13532 } // namespace v8 |
| OLD | NEW |