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

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 589573002: Fix JSBuiltinReducer to deal with non-JSFunction callees. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix typo. Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/graph-inl.h" 5 #include "src/compiler/graph-inl.h"
6 #include "src/compiler/js-builtin-reducer.h" 6 #include "src/compiler/js-builtin-reducer.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 10
(...skipping 16 matching lines...) Expand all
27 // Helper class to access JSCallFunction nodes that are potential candidates 27 // Helper class to access JSCallFunction nodes that are potential candidates
28 // for reduction when they have a BuiltinFunctionId associated with them. 28 // for reduction when they have a BuiltinFunctionId associated with them.
29 class JSCallReduction { 29 class JSCallReduction {
30 public: 30 public:
31 explicit JSCallReduction(Node* node) : node_(node) {} 31 explicit JSCallReduction(Node* node) : node_(node) {}
32 32
33 // Determines whether the node is a JSCallFunction operation that targets a 33 // Determines whether the node is a JSCallFunction operation that targets a
34 // constant callee being a well-known builtin with a BuiltinFunctionId. 34 // constant callee being a well-known builtin with a BuiltinFunctionId.
35 bool HasBuiltinFunctionId() { 35 bool HasBuiltinFunctionId() {
36 if (node_->opcode() != IrOpcode::kJSCallFunction) return false; 36 if (node_->opcode() != IrOpcode::kJSCallFunction) return false;
37 HeapObjectMatcher<JSFunction> m(NodeProperties::GetValueInput(node_, 0)); 37 HeapObjectMatcher<Object> m(NodeProperties::GetValueInput(node_, 0));
38 return m.HasValue() && m.Value().handle()->shared()->HasBuiltinFunctionId(); 38 if (!m.HasValue() || !m.Value().handle()->IsJSFunction()) return false;
39 Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value().handle());
40 return function->shared()->HasBuiltinFunctionId();
39 } 41 }
40 42
41 // Retrieves the BuiltinFunctionId as described above. 43 // Retrieves the BuiltinFunctionId as described above.
42 BuiltinFunctionId GetBuiltinFunctionId() { 44 BuiltinFunctionId GetBuiltinFunctionId() {
43 DCHECK_EQ(IrOpcode::kJSCallFunction, node_->opcode()); 45 DCHECK_EQ(IrOpcode::kJSCallFunction, node_->opcode());
44 HeapObjectMatcher<JSFunction> m(NodeProperties::GetValueInput(node_, 0)); 46 HeapObjectMatcher<Object> m(NodeProperties::GetValueInput(node_, 0));
45 return m.Value().handle()->shared()->builtin_function_id(); 47 Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value().handle());
48 return function->shared()->builtin_function_id();
46 } 49 }
47 50
48 // Determines whether the call takes one input of the given type. 51 // Determines whether the call takes one input of the given type.
49 bool InputsMatch(Type* t1) { 52 bool InputsMatch(Type* t1) {
50 return GetJSCallArity() == 1 && 53 return GetJSCallArity() == 1 &&
51 NodeProperties::GetBounds(GetJSCallInput(0)).upper->Is(t1); 54 NodeProperties::GetBounds(GetJSCallInput(0)).upper->Is(t1);
52 } 55 }
53 56
54 // Determines whether the call takes two inputs of the given types. 57 // Determines whether the call takes two inputs of the given types.
55 bool InputsMatch(Type* t1, Type* t2) { 58 bool InputsMatch(Type* t1, Type* t2) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return ReplaceWithPureReduction(node, ReduceMathImul(node)); 105 return ReplaceWithPureReduction(node, ReduceMathImul(node));
103 default: 106 default:
104 break; 107 break;
105 } 108 }
106 return NoChange(); 109 return NoChange();
107 } 110 }
108 111
109 } // namespace compiler 112 } // namespace compiler
110 } // namespace internal 113 } // namespace internal
111 } // namespace v8 114 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698