blob: 47a82d21850115b3c660f368ae8c68abceb82eb4 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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
3// found in the LICENSE file.
4
5#include "src/code-factory.h"
6#include "src/code-stubs.h"
7#include "src/compiler/common-operator.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/compiler/js-generic-lowering.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00009#include "src/compiler/js-graph.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000010#include "src/compiler/machine-operator.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -040011#include "src/compiler/node-matchers.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000012#include "src/compiler/node-properties.h"
13#include "src/compiler/operator-properties.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000014
15namespace v8 {
16namespace internal {
17namespace compiler {
18
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000019static CallDescriptor::Flags AdjustFrameStatesForCall(Node* node) {
20 int count = OperatorProperties::GetFrameStateInputCount(node->op());
21 if (count > 1) {
22 int index = NodeProperties::FirstFrameStateIndex(node) + 1;
23 do {
24 node->RemoveInput(index);
25 } while (--count > 1);
26 }
27 return count > 0 ? CallDescriptor::kNeedsFrameState
28 : CallDescriptor::kNoFlags;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000029}
30
Ben Murdochc5610432016-08-08 18:44:38 +010031JSGenericLowering::JSGenericLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000032
33JSGenericLowering::~JSGenericLowering() {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000034
35
Ben Murdochb8a8cc12014-11-26 15:28:44 +000036Reduction JSGenericLowering::Reduce(Node* node) {
37 switch (node->opcode()) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040038#define DECLARE_CASE(x) \
39 case IrOpcode::k##x: \
40 Lower##x(node); \
41 break;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000042 JS_OP_LIST(DECLARE_CASE)
43#undef DECLARE_CASE
44 default:
45 // Nothing to see.
46 return NoChange();
47 }
48 return Changed(node);
49}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000050#define REPLACE_RUNTIME_CALL(op, fun) \
51 void JSGenericLowering::Lower##op(Node* node) { \
52 ReplaceWithRuntimeCall(node, fun); \
53 }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000054REPLACE_RUNTIME_CALL(JSCreateWithContext, Runtime::kPushWithContext)
Ben Murdochb8a8cc12014-11-26 15:28:44 +000055REPLACE_RUNTIME_CALL(JSCreateModuleContext, Runtime::kPushModuleContext)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000056REPLACE_RUNTIME_CALL(JSConvertReceiver, Runtime::kConvertReceiver)
Ben Murdoch097c5b22016-05-18 11:27:45 +010057#undef REPLACE_RUNTIME_CALL
Ben Murdochb8a8cc12014-11-26 15:28:44 +000058
Ben Murdochda12d292016-06-02 14:46:10 +010059#define REPLACE_STUB_CALL(Name) \
60 void JSGenericLowering::LowerJS##Name(Node* node) { \
61 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); \
62 Callable callable = CodeFactory::Name(isolate()); \
63 ReplaceWithStubCall(node, callable, flags); \
64 }
65REPLACE_STUB_CALL(Add)
66REPLACE_STUB_CALL(Subtract)
Ben Murdochc5610432016-08-08 18:44:38 +010067REPLACE_STUB_CALL(Multiply)
68REPLACE_STUB_CALL(Divide)
69REPLACE_STUB_CALL(Modulus)
Ben Murdochda12d292016-06-02 14:46:10 +010070REPLACE_STUB_CALL(BitwiseAnd)
71REPLACE_STUB_CALL(BitwiseOr)
72REPLACE_STUB_CALL(BitwiseXor)
Ben Murdochc5610432016-08-08 18:44:38 +010073REPLACE_STUB_CALL(ShiftLeft)
74REPLACE_STUB_CALL(ShiftRight)
75REPLACE_STUB_CALL(ShiftRightLogical)
Ben Murdochda12d292016-06-02 14:46:10 +010076REPLACE_STUB_CALL(LessThan)
77REPLACE_STUB_CALL(LessThanOrEqual)
78REPLACE_STUB_CALL(GreaterThan)
79REPLACE_STUB_CALL(GreaterThanOrEqual)
Ben Murdochc5610432016-08-08 18:44:38 +010080REPLACE_STUB_CALL(HasProperty)
Ben Murdochda12d292016-06-02 14:46:10 +010081REPLACE_STUB_CALL(Equal)
82REPLACE_STUB_CALL(NotEqual)
Ben Murdochda12d292016-06-02 14:46:10 +010083REPLACE_STUB_CALL(ToInteger)
84REPLACE_STUB_CALL(ToLength)
85REPLACE_STUB_CALL(ToNumber)
86REPLACE_STUB_CALL(ToName)
87REPLACE_STUB_CALL(ToObject)
88REPLACE_STUB_CALL(ToString)
89#undef REPLACE_STUB_CALL
90
Ben Murdochb8a8cc12014-11-26 15:28:44 +000091void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
92 CallDescriptor::Flags flags) {
Ben Murdochc5610432016-08-08 18:44:38 +010093 ReplaceWithStubCall(node, callable, flags, node->op()->properties());
94}
95
96void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
97 CallDescriptor::Flags flags,
98 Operator::Properties properties) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000099 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
100 isolate(), zone(), callable.descriptor(), 0, flags, properties);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400101 Node* stub_code = jsgraph()->HeapConstant(callable.code());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000102 node->InsertInput(zone(), 0, stub_code);
103 NodeProperties::ChangeOp(node, common()->Call(desc));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000104}
105
106
107void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
108 Runtime::FunctionId f,
109 int nargs_override) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100110 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000111 Operator::Properties properties = node->op()->properties();
112 const Runtime::Function* fun = Runtime::FunctionForId(f);
113 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
Ben Murdoch097c5b22016-05-18 11:27:45 +0100114 CallDescriptor* desc =
115 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400116 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate()));
117 Node* arity = jsgraph()->Int32Constant(nargs);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000118 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
119 node->InsertInput(zone(), nargs + 1, ref);
120 node->InsertInput(zone(), nargs + 2, arity);
121 NodeProperties::ChangeOp(node, common()->Call(desc));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000122}
123
Ben Murdochc5610432016-08-08 18:44:38 +0100124void JSGenericLowering::LowerJSStrictEqual(Node* node) {
125 Callable callable = CodeFactory::StrictEqual(isolate());
126 node->AppendInput(zone(), graph()->start());
127 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
128 Operator::kEliminatable);
129}
130
131void JSGenericLowering::LowerJSStrictNotEqual(Node* node) {
132 Callable callable = CodeFactory::StrictNotEqual(isolate());
133 node->AppendInput(zone(), graph()->start());
134 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
135 Operator::kEliminatable);
136}
137
138void JSGenericLowering::LowerJSToBoolean(Node* node) {
139 Callable callable = CodeFactory::ToBoolean(isolate());
140 node->AppendInput(zone(), graph()->start());
141 ReplaceWithStubCall(node, callable, CallDescriptor::kNoAllocate,
142 Operator::kEliminatable);
143}
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000144
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000145void JSGenericLowering::LowerJSTypeOf(Node* node) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000146 Callable callable = CodeFactory::Typeof(isolate());
Ben Murdochc5610432016-08-08 18:44:38 +0100147 node->AppendInput(zone(), graph()->start());
148 ReplaceWithStubCall(node, callable, CallDescriptor::kNoAllocate,
149 Operator::kEliminatable);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000150}
151
152
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000153void JSGenericLowering::LowerJSLoadProperty(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100154 Node* closure = NodeProperties::GetValueInput(node, 2);
155 Node* effect = NodeProperties::GetEffectInput(node);
156 Node* control = NodeProperties::GetControlInput(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000157 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
158 const PropertyAccess& p = PropertyAccessOf(node->op());
Ben Murdoch61f157c2016-09-16 13:49:30 +0100159 Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100160 // Load the type feedback vector from the closure.
Ben Murdoch61f157c2016-09-16 13:49:30 +0100161 Node* literals = effect = graph()->NewNode(
Ben Murdoch097c5b22016-05-18 11:27:45 +0100162 machine()->Load(MachineType::AnyTagged()), closure,
Ben Murdoch61f157c2016-09-16 13:49:30 +0100163 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100164 effect, control);
165 Node* vector = effect = graph()->NewNode(
Ben Murdoch61f157c2016-09-16 13:49:30 +0100166 machine()->Load(MachineType::AnyTagged()), literals,
167 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
Ben Murdoch097c5b22016-05-18 11:27:45 +0100168 kHeapObjectTag),
169 effect, control);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000170 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100171 node->ReplaceInput(3, vector);
172 node->ReplaceInput(6, effect);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000173 ReplaceWithStubCall(node, callable, flags);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000174}
175
176
177void JSGenericLowering::LowerJSLoadNamed(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100178 Node* closure = NodeProperties::GetValueInput(node, 1);
179 Node* effect = NodeProperties::GetEffectInput(node);
180 Node* control = NodeProperties::GetControlInput(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000181 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
182 NamedAccess const& p = NamedAccessOf(node->op());
Ben Murdoch61f157c2016-09-16 13:49:30 +0100183 Callable callable = CodeFactory::LoadICInOptimizedCode(isolate());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100184 // Load the type feedback vector from the closure.
Ben Murdoch61f157c2016-09-16 13:49:30 +0100185 Node* literals = effect = graph()->NewNode(
Ben Murdoch097c5b22016-05-18 11:27:45 +0100186 machine()->Load(MachineType::AnyTagged()), closure,
Ben Murdoch61f157c2016-09-16 13:49:30 +0100187 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100188 effect, control);
189 Node* vector = effect = graph()->NewNode(
Ben Murdoch61f157c2016-09-16 13:49:30 +0100190 machine()->Load(MachineType::AnyTagged()), literals,
191 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
Ben Murdoch097c5b22016-05-18 11:27:45 +0100192 kHeapObjectTag),
193 effect, control);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000194 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
195 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100196 node->ReplaceInput(3, vector);
197 node->ReplaceInput(6, effect);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000198 ReplaceWithStubCall(node, callable, flags);
199}
200
201
202void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100203 Node* closure = NodeProperties::GetValueInput(node, 0);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000204 Node* effect = NodeProperties::GetEffectInput(node);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100205 Node* control = NodeProperties::GetControlInput(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000206 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
207 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
Ben Murdoch61f157c2016-09-16 13:49:30 +0100208 Callable callable =
209 CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100210 // Load the type feedback vector from the closure.
Ben Murdoch61f157c2016-09-16 13:49:30 +0100211 Node* literals = effect = graph()->NewNode(
Ben Murdoch097c5b22016-05-18 11:27:45 +0100212 machine()->Load(MachineType::AnyTagged()), closure,
Ben Murdoch61f157c2016-09-16 13:49:30 +0100213 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100214 effect, control);
215 Node* vector = effect = graph()->NewNode(
Ben Murdoch61f157c2016-09-16 13:49:30 +0100216 machine()->Load(MachineType::AnyTagged()), literals,
217 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
Ben Murdoch097c5b22016-05-18 11:27:45 +0100218 kHeapObjectTag),
219 effect, control);
Ben Murdoch61f157c2016-09-16 13:49:30 +0100220 node->InsertInput(zone(), 0, jsgraph()->SmiConstant(p.feedback().index()));
221 node->ReplaceInput(1, vector);
222 node->ReplaceInput(4, effect);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000223 ReplaceWithStubCall(node, callable, flags);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000224}
225
226
227void JSGenericLowering::LowerJSStoreProperty(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100228 Node* closure = NodeProperties::GetValueInput(node, 3);
229 Node* effect = NodeProperties::GetEffectInput(node);
230 Node* control = NodeProperties::GetControlInput(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000231 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
232 PropertyAccess const& p = PropertyAccessOf(node->op());
233 LanguageMode language_mode = p.language_mode();
Ben Murdoch61f157c2016-09-16 13:49:30 +0100234 Callable callable =
235 CodeFactory::KeyedStoreICInOptimizedCode(isolate(), language_mode);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100236 // Load the type feedback vector from the closure.
Ben Murdoch61f157c2016-09-16 13:49:30 +0100237 Node* literals = effect = graph()->NewNode(
Ben Murdoch097c5b22016-05-18 11:27:45 +0100238 machine()->Load(MachineType::AnyTagged()), closure,
Ben Murdoch61f157c2016-09-16 13:49:30 +0100239 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100240 effect, control);
241 Node* vector = effect = graph()->NewNode(
Ben Murdoch61f157c2016-09-16 13:49:30 +0100242 machine()->Load(MachineType::AnyTagged()), literals,
243 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
Ben Murdoch097c5b22016-05-18 11:27:45 +0100244 kHeapObjectTag),
245 effect, control);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000246 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100247 node->ReplaceInput(4, vector);
248 node->ReplaceInput(7, effect);
249 ReplaceWithStubCall(node, callable, flags);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000250}
251
252
253void JSGenericLowering::LowerJSStoreNamed(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100254 Node* closure = NodeProperties::GetValueInput(node, 2);
255 Node* effect = NodeProperties::GetEffectInput(node);
256 Node* control = NodeProperties::GetControlInput(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000257 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
258 NamedAccess const& p = NamedAccessOf(node->op());
Ben Murdoch61f157c2016-09-16 13:49:30 +0100259 Callable callable =
260 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100261 // Load the type feedback vector from the closure.
Ben Murdoch61f157c2016-09-16 13:49:30 +0100262 Node* literals = effect = graph()->NewNode(
Ben Murdoch097c5b22016-05-18 11:27:45 +0100263 machine()->Load(MachineType::AnyTagged()), closure,
Ben Murdoch61f157c2016-09-16 13:49:30 +0100264 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100265 effect, control);
266 Node* vector = effect = graph()->NewNode(
Ben Murdoch61f157c2016-09-16 13:49:30 +0100267 machine()->Load(MachineType::AnyTagged()), literals,
268 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
Ben Murdoch097c5b22016-05-18 11:27:45 +0100269 kHeapObjectTag),
270 effect, control);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000271 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000272 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100273 node->ReplaceInput(4, vector);
274 node->ReplaceInput(7, effect);
275 ReplaceWithStubCall(node, callable, flags);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000276}
277
278
279void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100280 Node* closure = NodeProperties::GetValueInput(node, 1);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000281 Node* context = NodeProperties::GetContextInput(node);
282 Node* effect = NodeProperties::GetEffectInput(node);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100283 Node* control = NodeProperties::GetControlInput(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000284 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
285 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
Ben Murdoch61f157c2016-09-16 13:49:30 +0100286 Callable callable =
287 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100288 // Load the type feedback vector from the closure.
Ben Murdoch61f157c2016-09-16 13:49:30 +0100289 Node* literals = effect = graph()->NewNode(
Ben Murdoch097c5b22016-05-18 11:27:45 +0100290 machine()->Load(MachineType::AnyTagged()), closure,
Ben Murdoch61f157c2016-09-16 13:49:30 +0100291 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100292 effect, control);
293 Node* vector = effect = graph()->NewNode(
Ben Murdoch61f157c2016-09-16 13:49:30 +0100294 machine()->Load(MachineType::AnyTagged()), literals,
295 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset -
Ben Murdoch097c5b22016-05-18 11:27:45 +0100296 kHeapObjectTag),
297 effect, control);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000298 // Load global object from the context.
Ben Murdoch097c5b22016-05-18 11:27:45 +0100299 Node* native_context = effect =
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000300 graph()->NewNode(machine()->Load(MachineType::AnyTagged()), context,
301 jsgraph()->IntPtrConstant(
302 Context::SlotOffset(Context::NATIVE_CONTEXT_INDEX)),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100303 effect, control);
304 Node* global = effect = graph()->NewNode(
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000305 machine()->Load(MachineType::AnyTagged()), native_context,
306 jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100307 effect, control);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000308 node->InsertInput(zone(), 0, global);
309 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000310 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100311 node->ReplaceInput(4, vector);
312 node->ReplaceInput(7, effect);
313 ReplaceWithStubCall(node, callable, flags);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000314}
315
316
317void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000318 LanguageMode language_mode = OpParameter<LanguageMode>(node);
319 ReplaceWithRuntimeCall(node, is_strict(language_mode)
320 ? Runtime::kDeleteProperty_Strict
321 : Runtime::kDeleteProperty_Sloppy);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000322}
323
324
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000325void JSGenericLowering::LowerJSInstanceOf(Node* node) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000326 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
327 Callable callable = CodeFactory::InstanceOf(isolate());
328 ReplaceWithStubCall(node, callable, flags);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000329}
330
331
332void JSGenericLowering::LowerJSLoadContext(Node* node) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400333 const ContextAccess& access = ContextAccessOf(node->op());
334 for (size_t i = 0; i < access.depth(); ++i) {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000335 node->ReplaceInput(
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000336 0, graph()->NewNode(machine()->Load(MachineType::AnyTagged()),
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400337 NodeProperties::GetValueInput(node, 0),
338 jsgraph()->Int32Constant(
339 Context::SlotOffset(Context::PREVIOUS_INDEX)),
340 NodeProperties::GetEffectInput(node),
341 graph()->start()));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000342 }
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400343 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
344 static_cast<int>(access.index()))));
345 node->AppendInput(zone(), graph()->start());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000346 NodeProperties::ChangeOp(node, machine()->Load(MachineType::AnyTagged()));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000347}
348
349
350void JSGenericLowering::LowerJSStoreContext(Node* node) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400351 const ContextAccess& access = ContextAccessOf(node->op());
352 for (size_t i = 0; i < access.depth(); ++i) {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000353 node->ReplaceInput(
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000354 0, graph()->NewNode(machine()->Load(MachineType::AnyTagged()),
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400355 NodeProperties::GetValueInput(node, 0),
356 jsgraph()->Int32Constant(
357 Context::SlotOffset(Context::PREVIOUS_INDEX)),
358 NodeProperties::GetEffectInput(node),
359 graph()->start()));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000360 }
361 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400362 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
363 static_cast<int>(access.index()))));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000364 NodeProperties::ChangeOp(
365 node, machine()->Store(StoreRepresentation(MachineRepresentation::kTagged,
366 kFullWriteBarrier)));
367}
368
369
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000370void JSGenericLowering::LowerJSCreate(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100371 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
372 Callable callable = CodeFactory::FastNewObject(isolate());
373 ReplaceWithStubCall(node, callable, flags);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000374}
375
376
377void JSGenericLowering::LowerJSCreateArguments(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100378 CreateArgumentsType const type = CreateArgumentsTypeOf(node->op());
379 switch (type) {
380 case CreateArgumentsType::kMappedArguments:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000381 ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic);
382 break;
Ben Murdoch097c5b22016-05-18 11:27:45 +0100383 case CreateArgumentsType::kUnmappedArguments:
384 ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000385 break;
Ben Murdoch097c5b22016-05-18 11:27:45 +0100386 case CreateArgumentsType::kRestParameter:
387 ReplaceWithRuntimeCall(node, Runtime::kNewRestParameter);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000388 break;
389 }
390}
391
392
393void JSGenericLowering::LowerJSCreateArray(Node* node) {
394 CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
395 int const arity = static_cast<int>(p.arity());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100396 Handle<AllocationSite> const site = p.site();
397
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000398 // TODO(turbofan): We embed the AllocationSite from the Operator at this
399 // point, which we should not do once we want to both consume the feedback
400 // but at the same time shared the optimized code across native contexts,
401 // as the AllocationSite is associated with a single native context (it's
402 // stored in the type feedback vector after all). Once we go for cross
403 // context code generation, we should somehow find a way to get to the
404 // allocation site for the actual native context at runtime.
Ben Murdoch097c5b22016-05-18 11:27:45 +0100405 if (!site.is_null()) {
406 // Reduce {node} to the appropriate ArrayConstructorStub backend.
407 // Note that these stubs "behave" like JSFunctions, which means they
408 // expect a receiver on the stack, which they remove. We just push
409 // undefined for the receiver.
410 ElementsKind elements_kind = site->GetElementsKind();
411 AllocationSiteOverrideMode override_mode =
412 (AllocationSite::GetMode(elements_kind) == TRACK_ALLOCATION_SITE)
413 ? DISABLE_ALLOCATION_SITES
414 : DONT_OVERRIDE;
415 if (arity == 0) {
416 ArrayNoArgumentConstructorStub stub(isolate(), elements_kind,
417 override_mode);
418 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
419 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 1,
420 CallDescriptor::kNeedsFrameState);
421 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
422 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site));
Ben Murdoch61f157c2016-09-16 13:49:30 +0100423 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(0));
424 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100425 NodeProperties::ChangeOp(node, common()->Call(desc));
426 } else if (arity == 1) {
427 // TODO(bmeurer): Optimize for the 0 length non-holey case?
428 ArraySingleArgumentConstructorStub stub(
429 isolate(), GetHoleyElementsKind(elements_kind), override_mode);
430 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
431 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2,
432 CallDescriptor::kNeedsFrameState);
433 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
434 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site));
435 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(1));
436 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
437 NodeProperties::ChangeOp(node, common()->Call(desc));
438 } else {
Ben Murdoch61f157c2016-09-16 13:49:30 +0100439 ArrayNArgumentsConstructorStub stub(isolate());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100440 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
441 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(),
442 arity + 1, CallDescriptor::kNeedsFrameState);
443 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
444 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site));
445 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity));
446 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
447 NodeProperties::ChangeOp(node, common()->Call(desc));
448 }
449 } else {
450 Node* new_target = node->InputAt(1);
451 Node* type_info = site.is_null() ? jsgraph()->UndefinedConstant()
452 : jsgraph()->HeapConstant(site);
453 node->RemoveInput(1);
454 node->InsertInput(zone(), 1 + arity, new_target);
455 node->InsertInput(zone(), 2 + arity, type_info);
456 ReplaceWithRuntimeCall(node, Runtime::kNewArray, arity + 3);
457 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000458}
459
460
461void JSGenericLowering::LowerJSCreateClosure(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100462 CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
463 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
464 Handle<SharedFunctionInfo> const shared_info = p.shared_info();
465 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info));
466
Ben Murdoch61f157c2016-09-16 13:49:30 +0100467 // Use the FastNewClosureStub only for functions allocated in new space.
468 if (p.pretenure() == NOT_TENURED) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100469 Callable callable = CodeFactory::FastNewClosure(
470 isolate(), shared_info->language_mode(), shared_info->kind());
471 ReplaceWithStubCall(node, callable, flags);
472 } else {
473 ReplaceWithRuntimeCall(node, (p.pretenure() == TENURED)
474 ? Runtime::kNewClosure_Tenured
475 : Runtime::kNewClosure);
476 }
477}
478
479
480void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
481 int const slot_count = OpParameter<int>(node->op());
482 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
483
484 // Use the FastNewContextStub only for function contexts up maximum size.
485 if (slot_count <= FastNewContextStub::kMaximumSlots) {
486 Callable callable = CodeFactory::FastNewContext(isolate(), slot_count);
487 ReplaceWithStubCall(node, callable, flags);
488 } else {
489 ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
490 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000491}
492
493
494void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) {
495 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject);
496}
497
498
499void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
500 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100501 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000502 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index()));
503 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100504
505 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the
506 // initial length limit for arrays with "fast" elements kind.
507 if ((p.flags() & ArrayLiteral::kShallowElements) != 0 &&
Ben Murdochda12d292016-06-02 14:46:10 +0100508 p.length() < JSArray::kInitialMaxFastElementArray) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100509 Callable callable = CodeFactory::FastCloneShallowArray(isolate());
510 ReplaceWithStubCall(node, callable, flags);
511 } else {
512 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
513 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
514 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000515}
516
517
518void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
519 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100520 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000521 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index()));
522 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
523 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
Ben Murdoch097c5b22016-05-18 11:27:45 +0100524
525 // Use the FastCloneShallowObjectStub only for shallow boilerplates without
526 // elements up to the number of properties that the stubs can handle.
527 if ((p.flags() & ObjectLiteral::kShallowProperties) != 0 &&
Ben Murdochda12d292016-06-02 14:46:10 +0100528 p.length() <= FastCloneShallowObjectStub::kMaximumClonedProperties) {
529 Callable callable =
530 CodeFactory::FastCloneShallowObject(isolate(), p.length());
Ben Murdoch097c5b22016-05-18 11:27:45 +0100531 ReplaceWithStubCall(node, callable, flags);
532 } else {
533 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
534 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000535}
536
537
538void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) {
539 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
540 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
541 Callable callable = CodeFactory::FastCloneRegExp(isolate());
542 Node* literal_index = jsgraph()->SmiConstant(p.index());
543 Node* literal_flags = jsgraph()->SmiConstant(p.flags());
544 Node* pattern = jsgraph()->HeapConstant(p.constant());
545 node->InsertInput(graph()->zone(), 1, literal_index);
546 node->InsertInput(graph()->zone(), 2, pattern);
547 node->InsertInput(graph()->zone(), 3, literal_flags);
548 ReplaceWithStubCall(node, callable, flags);
549}
550
551
552void JSGenericLowering::LowerJSCreateCatchContext(Node* node) {
553 Handle<String> name = OpParameter<Handle<String>>(node);
554 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name));
555 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext);
556}
557
558
559void JSGenericLowering::LowerJSCreateBlockContext(Node* node) {
560 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node);
561 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
562 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext);
563}
564
565
566void JSGenericLowering::LowerJSCreateScriptContext(Node* node) {
567 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node);
568 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info));
569 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000570}
571
572
573void JSGenericLowering::LowerJSCallConstruct(Node* node) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000574 CallConstructParameters const& p = CallConstructParametersOf(node->op());
575 int const arg_count = static_cast<int>(p.arity() - 2);
576 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
577 Callable callable = CodeFactory::Construct(isolate());
578 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
579 isolate(), zone(), callable.descriptor(), arg_count + 1, flags);
580 Node* stub_code = jsgraph()->HeapConstant(callable.code());
581 Node* stub_arity = jsgraph()->Int32Constant(arg_count);
582 Node* new_target = node->InputAt(arg_count + 1);
583 Node* receiver = jsgraph()->UndefinedConstant();
584 node->RemoveInput(arg_count + 1); // Drop new target.
585 node->InsertInput(zone(), 0, stub_code);
586 node->InsertInput(zone(), 2, new_target);
587 node->InsertInput(zone(), 3, stub_arity);
588 node->InsertInput(zone(), 4, receiver);
589 NodeProperties::ChangeOp(node, common()->Call(desc));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400590}
591
592
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000593void JSGenericLowering::LowerJSCallFunction(Node* node) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000594 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
595 int const arg_count = static_cast<int>(p.arity() - 2);
596 ConvertReceiverMode const mode = p.convert_mode();
597 Callable callable = CodeFactory::Call(isolate(), mode);
598 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
599 if (p.tail_call_mode() == TailCallMode::kAllow) {
600 flags |= CallDescriptor::kSupportsTailCalls;
601 }
602 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
603 isolate(), zone(), callable.descriptor(), arg_count + 1, flags);
604 Node* stub_code = jsgraph()->HeapConstant(callable.code());
605 Node* stub_arity = jsgraph()->Int32Constant(arg_count);
606 node->InsertInput(zone(), 0, stub_code);
607 node->InsertInput(zone(), 2, stub_arity);
608 NodeProperties::ChangeOp(node, common()->Call(desc));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000609}
610
611
612void JSGenericLowering::LowerJSCallRuntime(Node* node) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400613 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000614 AdjustFrameStatesForCall(node);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400615 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000616}
617
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000618
619void JSGenericLowering::LowerJSForInDone(Node* node) {
620 ReplaceWithRuntimeCall(node, Runtime::kForInDone);
621}
622
623
624void JSGenericLowering::LowerJSForInNext(Node* node) {
625 ReplaceWithRuntimeCall(node, Runtime::kForInNext);
626}
627
628
629void JSGenericLowering::LowerJSForInPrepare(Node* node) {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100630 ReplaceWithRuntimeCall(node, Runtime::kForInPrepare);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000631}
632
633
634void JSGenericLowering::LowerJSForInStep(Node* node) {
635 ReplaceWithRuntimeCall(node, Runtime::kForInStep);
636}
637
638
639void JSGenericLowering::LowerJSLoadMessage(Node* node) {
640 ExternalReference message_address =
641 ExternalReference::address_of_pending_message_obj(isolate());
642 node->RemoveInput(NodeProperties::FirstContextIndex(node));
643 node->InsertInput(zone(), 0, jsgraph()->ExternalConstant(message_address));
644 node->InsertInput(zone(), 1, jsgraph()->IntPtrConstant(0));
645 NodeProperties::ChangeOp(node, machine()->Load(MachineType::AnyTagged()));
646}
647
648
649void JSGenericLowering::LowerJSStoreMessage(Node* node) {
650 ExternalReference message_address =
651 ExternalReference::address_of_pending_message_obj(isolate());
652 node->RemoveInput(NodeProperties::FirstContextIndex(node));
653 node->InsertInput(zone(), 0, jsgraph()->ExternalConstant(message_address));
654 node->InsertInput(zone(), 1, jsgraph()->IntPtrConstant(0));
655 StoreRepresentation representation(MachineRepresentation::kTagged,
656 kNoWriteBarrier);
657 NodeProperties::ChangeOp(node, machine()->Store(representation));
658}
659
Ben Murdoch61f157c2016-09-16 13:49:30 +0100660void JSGenericLowering::LowerJSGeneratorStore(Node* node) {
661 UNREACHABLE(); // Eliminated in typed lowering.
662}
663
664void JSGenericLowering::LowerJSGeneratorRestoreContinuation(Node* node) {
665 UNREACHABLE(); // Eliminated in typed lowering.
666}
667
668void JSGenericLowering::LowerJSGeneratorRestoreRegister(Node* node) {
669 UNREACHABLE(); // Eliminated in typed lowering.
670}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000671
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000672void JSGenericLowering::LowerJSStackCheck(Node* node) {
673 Node* effect = NodeProperties::GetEffectInput(node);
674 Node* control = NodeProperties::GetControlInput(node);
675
676 Node* limit = graph()->NewNode(
677 machine()->Load(MachineType::Pointer()),
678 jsgraph()->ExternalConstant(
679 ExternalReference::address_of_stack_limit(isolate())),
680 jsgraph()->IntPtrConstant(0), effect, control);
681 Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
682
683 Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
684 Node* branch =
685 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
686
687 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
688 Node* etrue = effect;
689
690 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
691 NodeProperties::ReplaceControlInput(node, if_false);
692 Node* efalse = node;
693
694 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
695 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
696
697 // Wire the new diamond into the graph, {node} can still throw.
698 NodeProperties::ReplaceUses(node, node, ephi, node, node);
699 NodeProperties::ReplaceEffectInput(ephi, efalse, 1);
700
701 // TODO(mstarzinger): This iteration cuts out the IfSuccess projection from
702 // the node and places it inside the diamond. Come up with a helper method!
703 for (Node* use : node->uses()) {
704 if (use->opcode() == IrOpcode::kIfSuccess) {
705 use->ReplaceUses(merge);
706 merge->ReplaceInput(1, use);
707 }
708 }
709
710 // Turn the stack check into a runtime call.
711 ReplaceWithRuntimeCall(node, Runtime::kStackGuard);
712}
713
714
715Zone* JSGenericLowering::zone() const { return graph()->zone(); }
716
717
718Isolate* JSGenericLowering::isolate() const { return jsgraph()->isolate(); }
719
720
721Graph* JSGenericLowering::graph() const { return jsgraph()->graph(); }
722
723
724CommonOperatorBuilder* JSGenericLowering::common() const {
725 return jsgraph()->common();
726}
727
728
729MachineOperatorBuilder* JSGenericLowering::machine() const {
730 return jsgraph()->machine();
731}
732
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000733} // namespace compiler
734} // namespace internal
735} // namespace v8