Chromium Code Reviews| 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 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2050 Push(Add<HCallRuntime>( | 2050 Push(Add<HCallRuntime>( |
| 2051 Runtime::FunctionForId(Runtime::kNumberToStringSkipCache), | 2051 Runtime::FunctionForId(Runtime::kNumberToStringSkipCache), |
| 2052 1)); | 2052 1)); |
| 2053 } | 2053 } |
| 2054 if_found.End(); | 2054 if_found.End(); |
| 2055 | 2055 |
| 2056 return Pop(); | 2056 return Pop(); |
| 2057 } | 2057 } |
| 2058 | 2058 |
| 2059 | 2059 |
| 2060 HValue* HGraphBuilder::BuildToNumber(HValue* input, Type* input_type) { | |
| 2061 if (input->type().IsTaggedNumber() || input_type->Is(Type::Number())) { | |
| 2062 return input; | |
| 2063 } | |
| 2064 Callable callable = CodeFactory::ToNumber(isolate()); | |
| 2065 HValue* stub = Add<HConstant>(callable.code()); | |
| 2066 HValue* values[] = {context(), input}; | |
| 2067 HCallWithDescriptor* instr = | |
| 2068 Add<HCallWithDescriptor>(stub, 0, callable.descriptor(), | |
| 2069 Vector<HValue*>(values, arraysize(values))); | |
| 2070 instr->set_type(HType::TaggedNumber()); | |
| 2071 return instr; | |
| 2072 } | |
| 2073 | |
| 2074 | |
| 2060 HValue* HGraphBuilder::BuildToObject(HValue* receiver) { | 2075 HValue* HGraphBuilder::BuildToObject(HValue* receiver) { |
| 2061 NoObservableSideEffectsScope scope(this); | 2076 NoObservableSideEffectsScope scope(this); |
| 2062 | 2077 |
| 2063 // Create a joinable continuation. | 2078 // Create a joinable continuation. |
| 2064 HIfContinuation wrap(graph()->CreateBasicBlock(), | 2079 HIfContinuation wrap(graph()->CreateBasicBlock(), |
| 2065 graph()->CreateBasicBlock()); | 2080 graph()->CreateBasicBlock()); |
| 2066 | 2081 |
| 2067 // Determine the proper global constructor function required to wrap | 2082 // Determine the proper global constructor function required to wrap |
| 2068 // {receiver} into a JSValue, unless {receiver} is already a {JSReceiver}, in | 2083 // {receiver} into a JSValue, unless {receiver} is already a {JSReceiver}, in |
| 2069 // which case we just return it. Deopts to Runtime::kToObject if {receiver} | 2084 // which case we just return it. Deopts to Runtime::kToObject if {receiver} |
| (...skipping 9061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11131 ConsString::kMinLength)) { | 11146 ConsString::kMinLength)) { |
| 11132 return BuildStringAdd(left, right, allocation_mode); | 11147 return BuildStringAdd(left, right, allocation_mode); |
| 11133 } | 11148 } |
| 11134 | 11149 |
| 11135 // Fallback to using the string add stub. | 11150 // Fallback to using the string add stub. |
| 11136 return AddUncasted<HStringAdd>( | 11151 return AddUncasted<HStringAdd>( |
| 11137 left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CHECK_NONE, | 11152 left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CHECK_NONE, |
| 11138 allocation_mode.feedback_site()); | 11153 allocation_mode.feedback_site()); |
| 11139 } | 11154 } |
| 11140 | 11155 |
| 11156 // Special case for +x here. | |
| 11157 if (op == Token::MUL) { | |
| 11158 if (left->EqualsInteger32Constant(1)) { | |
| 11159 return BuildToNumber(right, right_type); | |
|
Jakob Kummerow
2016/03/02 15:06:18
You can't trust |right_type| and |left_type| at th
Benedikt Meurer
2016/03/02 18:35:23
Crankshaft...
| |
| 11160 } | |
| 11161 if (right->EqualsInteger32Constant(1)) { | |
| 11162 return BuildToNumber(left, left_type); | |
| 11163 } | |
| 11164 } | |
| 11165 | |
| 11141 if (graph()->info()->IsStub()) { | 11166 if (graph()->info()->IsStub()) { |
| 11142 left = EnforceNumberType(left, left_type); | 11167 left = EnforceNumberType(left, left_type); |
| 11143 right = EnforceNumberType(right, right_type); | 11168 right = EnforceNumberType(right, right_type); |
| 11144 } | 11169 } |
| 11145 | 11170 |
| 11146 Representation result_rep = RepresentationFor(result_type); | 11171 Representation result_rep = RepresentationFor(result_type); |
| 11147 | 11172 |
| 11148 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || | 11173 bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || |
| 11149 (right_rep.IsTagged() && !right_rep.IsSmi()); | 11174 (right_rep.IsTagged() && !right_rep.IsSmi()); |
| 11150 | 11175 |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12355 Vector<HValue*>(values, arraysize(values))); | 12380 Vector<HValue*>(values, arraysize(values))); |
| 12356 return ast_context()->ReturnInstruction(result, call->id()); | 12381 return ast_context()->ReturnInstruction(result, call->id()); |
| 12357 } | 12382 } |
| 12358 | 12383 |
| 12359 | 12384 |
| 12360 void HOptimizedGraphBuilder::GenerateToNumber(CallRuntime* call) { | 12385 void HOptimizedGraphBuilder::GenerateToNumber(CallRuntime* call) { |
| 12361 DCHECK_EQ(1, call->arguments()->length()); | 12386 DCHECK_EQ(1, call->arguments()->length()); |
| 12362 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12387 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 12363 Callable callable = CodeFactory::ToNumber(isolate()); | 12388 Callable callable = CodeFactory::ToNumber(isolate()); |
| 12364 HValue* input = Pop(); | 12389 HValue* input = Pop(); |
| 12365 if (input->type().IsTaggedNumber()) { | 12390 Type* input_type = Type::Any(); |
| 12366 return ast_context()->ReturnValue(input); | 12391 HValue* result = BuildToNumber(input, input_type); |
| 12367 } else { | 12392 if (result->HasObservableSideEffects()) { |
| 12368 HValue* stub = Add<HConstant>(callable.code()); | 12393 if (!ast_context()->IsEffect()) Push(result); |
| 12369 HValue* values[] = {context(), input}; | 12394 Add<HSimulate>(call->id(), REMOVABLE_SIMULATE); |
| 12370 HInstruction* result = | 12395 if (!ast_context()->IsEffect()) result = Pop(); |
| 12371 New<HCallWithDescriptor>(stub, 0, callable.descriptor(), | |
| 12372 Vector<HValue*>(values, arraysize(values))); | |
| 12373 return ast_context()->ReturnInstruction(result, call->id()); | |
| 12374 } | 12396 } |
| 12397 return ast_context()->ReturnValue(result); | |
| 12375 } | 12398 } |
| 12376 | 12399 |
| 12377 | 12400 |
| 12378 void HOptimizedGraphBuilder::GenerateIsJSProxy(CallRuntime* call) { | 12401 void HOptimizedGraphBuilder::GenerateIsJSProxy(CallRuntime* call) { |
| 12379 DCHECK(call->arguments()->length() == 1); | 12402 DCHECK(call->arguments()->length() == 1); |
| 12380 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12403 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 12381 HValue* value = Pop(); | 12404 HValue* value = Pop(); |
| 12382 HIfContinuation continuation; | 12405 HIfContinuation continuation; |
| 12383 IfBuilder if_proxy(this); | 12406 IfBuilder if_proxy(this); |
| 12384 | 12407 |
| (...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13538 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13561 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13539 } | 13562 } |
| 13540 | 13563 |
| 13541 #ifdef DEBUG | 13564 #ifdef DEBUG |
| 13542 graph_->Verify(false); // No full verify. | 13565 graph_->Verify(false); // No full verify. |
| 13543 #endif | 13566 #endif |
| 13544 } | 13567 } |
| 13545 | 13568 |
| 13546 } // namespace internal | 13569 } // namespace internal |
| 13547 } // namespace v8 | 13570 } // namespace v8 |
| OLD | NEW |