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

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 1757013002: [crankshaft] Fix invalid ToNumber optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | test/mjsunit/regress/regress-crbug-590989-1.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 9008 matching lines...) Expand 10 before | Expand all | Expand 10 after
11074 11073
11075 // Fallback to using the string add stub. 11074 // Fallback to using the string add stub.
11076 return AddUncasted<HStringAdd>( 11075 return AddUncasted<HStringAdd>(
11077 left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CHECK_NONE, 11076 left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CHECK_NONE,
11078 allocation_mode.feedback_site()); 11077 allocation_mode.feedback_site());
11079 } 11078 }
11080 11079
11081 // Special case for +x here. 11080 // Special case for +x here.
11082 if (op == Token::MUL) { 11081 if (op == Token::MUL) {
11083 if (left->EqualsInteger32Constant(1)) { 11082 if (left->EqualsInteger32Constant(1)) {
11084 return BuildToNumber(right, right_type); 11083 return BuildToNumber(right);
11085 } 11084 }
11086 if (right->EqualsInteger32Constant(1)) { 11085 if (right->EqualsInteger32Constant(1)) {
11087 return BuildToNumber(left, left_type); 11086 return BuildToNumber(left);
11088 } 11087 }
11089 } 11088 }
11090 11089
11091 if (graph()->info()->IsStub()) { 11090 if (graph()->info()->IsStub()) {
11092 left = EnforceNumberType(left, left_type); 11091 left = EnforceNumberType(left, left_type);
11093 right = EnforceNumberType(right, right_type); 11092 right = EnforceNumberType(right, right_type);
11094 } 11093 }
11095 11094
11096 Representation result_rep = RepresentationFor(result_type); 11095 Representation result_rep = RepresentationFor(result_type);
11097 11096
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
12300 Vector<HValue*>(values, arraysize(values))); 12299 Vector<HValue*>(values, arraysize(values)));
12301 return ast_context()->ReturnInstruction(result, call->id()); 12300 return ast_context()->ReturnInstruction(result, call->id());
12302 } 12301 }
12303 12302
12304 12303
12305 void HOptimizedGraphBuilder::GenerateToNumber(CallRuntime* call) { 12304 void HOptimizedGraphBuilder::GenerateToNumber(CallRuntime* call) {
12306 DCHECK_EQ(1, call->arguments()->length()); 12305 DCHECK_EQ(1, call->arguments()->length());
12307 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 12306 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
12308 Callable callable = CodeFactory::ToNumber(isolate()); 12307 Callable callable = CodeFactory::ToNumber(isolate());
12309 HValue* input = Pop(); 12308 HValue* input = Pop();
12310 Type* input_type = Type::Any(); 12309 HValue* result = BuildToNumber(input);
12311 HValue* result = BuildToNumber(input, input_type);
12312 if (result->HasObservableSideEffects()) { 12310 if (result->HasObservableSideEffects()) {
12313 if (!ast_context()->IsEffect()) Push(result); 12311 if (!ast_context()->IsEffect()) Push(result);
12314 Add<HSimulate>(call->id(), REMOVABLE_SIMULATE); 12312 Add<HSimulate>(call->id(), REMOVABLE_SIMULATE);
12315 if (!ast_context()->IsEffect()) result = Pop(); 12313 if (!ast_context()->IsEffect()) result = Pop();
12316 } 12314 }
12317 return ast_context()->ReturnValue(result); 12315 return ast_context()->ReturnValue(result);
12318 } 12316 }
12319 12317
12320 12318
12321 void HOptimizedGraphBuilder::GenerateIsJSProxy(CallRuntime* call) { 12319 void HOptimizedGraphBuilder::GenerateIsJSProxy(CallRuntime* call) {
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
13472 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13470 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13473 } 13471 }
13474 13472
13475 #ifdef DEBUG 13473 #ifdef DEBUG
13476 graph_->Verify(false); // No full verify. 13474 graph_->Verify(false); // No full verify.
13477 #endif 13475 #endif
13478 } 13476 }
13479 13477
13480 } // namespace internal 13478 } // namespace internal
13481 } // namespace v8 13479 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | test/mjsunit/regress/regress-crbug-590989-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698