OLD | NEW |
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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/graph-inl.h" | 8 #include "src/compiler/graph-inl.h" |
9 #include "src/compiler/js-generic-lowering.h" | 9 #include "src/compiler/js-generic-lowering.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 PatchInsertInput(node, 0, stub_code); | 191 PatchInsertInput(node, 0, stub_code); |
192 PatchOperator(node, common()->Call(desc)); | 192 PatchOperator(node, common()->Call(desc)); |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, | 196 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, |
197 Builtins::JavaScript id, | 197 Builtins::JavaScript id, |
198 int nargs) { | 198 int nargs) { |
199 Callable callable = | 199 Callable callable = |
200 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); | 200 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); |
201 CallDescriptor* desc = | 201 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
202 linkage()->GetStubCallDescriptor(callable.descriptor(), nargs); | 202 callable.descriptor(), nargs, FlagsForNode(node)); |
203 // TODO(mstarzinger): Accessing the builtins object this way prevents sharing | 203 // TODO(mstarzinger): Accessing the builtins object this way prevents sharing |
204 // of code across native contexts. Fix this by loading from given context. | 204 // of code across native contexts. Fix this by loading from given context. |
205 Handle<JSFunction> function( | 205 Handle<JSFunction> function( |
206 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id))); | 206 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id))); |
207 Node* stub_code = CodeConstant(callable.code()); | 207 Node* stub_code = CodeConstant(callable.code()); |
208 Node* function_node = FunctionConstant(function); | 208 Node* function_node = FunctionConstant(function); |
209 PatchInsertInput(node, 0, stub_code); | 209 PatchInsertInput(node, 0, stub_code); |
210 PatchInsertInput(node, 1, function_node); | 210 PatchInsertInput(node, 1, function_node); |
211 PatchOperator(node, common()->Call(desc)); | 211 PatchOperator(node, common()->Call(desc)); |
212 } | 212 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 void JSGenericLowering::LowerJSToBoolean(Node* node) { | 254 void JSGenericLowering::LowerJSToBoolean(Node* node) { |
255 Callable callable = | 255 Callable callable = |
256 CodeFactory::ToBoolean(isolate(), ToBooleanStub::RESULT_AS_ODDBALL); | 256 CodeFactory::ToBoolean(isolate(), ToBooleanStub::RESULT_AS_ODDBALL); |
257 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 257 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); |
258 } | 258 } |
259 | 259 |
260 | 260 |
261 void JSGenericLowering::LowerJSToNumber(Node* node) { | 261 void JSGenericLowering::LowerJSToNumber(Node* node) { |
262 Callable callable = CodeFactory::ToNumber(isolate()); | 262 Callable callable = CodeFactory::ToNumber(isolate()); |
263 ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags); | 263 ReplaceWithStubCall(node, callable, FlagsForNode(node)); |
264 } | 264 } |
265 | 265 |
266 | 266 |
267 void JSGenericLowering::LowerJSToString(Node* node) { | 267 void JSGenericLowering::LowerJSToString(Node* node) { |
268 ReplaceWithBuiltinCall(node, Builtins::TO_STRING, 1); | 268 ReplaceWithBuiltinCall(node, Builtins::TO_STRING, 1); |
269 } | 269 } |
270 | 270 |
271 | 271 |
272 void JSGenericLowering::LowerJSToObject(Node* node) { | 272 void JSGenericLowering::LowerJSToObject(Node* node) { |
273 ReplaceWithBuiltinCall(node, Builtins::TO_OBJECT, 1); | 273 ReplaceWithBuiltinCall(node, Builtins::TO_OBJECT, 1); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ReplaceWithBuiltinCall(node, Builtins::IN, 2); | 314 ReplaceWithBuiltinCall(node, Builtins::IN, 2); |
315 } | 315 } |
316 | 316 |
317 | 317 |
318 void JSGenericLowering::LowerJSInstanceOf(Node* node) { | 318 void JSGenericLowering::LowerJSInstanceOf(Node* node) { |
319 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( | 319 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( |
320 InstanceofStub::kReturnTrueFalseObject | | 320 InstanceofStub::kReturnTrueFalseObject | |
321 InstanceofStub::kArgsInRegisters); | 321 InstanceofStub::kArgsInRegisters); |
322 InstanceofStub stub(isolate(), flags); | 322 InstanceofStub stub(isolate(), flags); |
323 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 323 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |
324 CallDescriptor* desc = linkage()->GetStubCallDescriptor(d, 0); | 324 CallDescriptor* desc = |
| 325 linkage()->GetStubCallDescriptor(d, 0, FlagsForNode(node)); |
325 Node* stub_code = CodeConstant(stub.GetCode()); | 326 Node* stub_code = CodeConstant(stub.GetCode()); |
326 PatchInsertInput(node, 0, stub_code); | 327 PatchInsertInput(node, 0, stub_code); |
327 PatchOperator(node, common()->Call(desc)); | 328 PatchOperator(node, common()->Call(desc)); |
328 } | 329 } |
329 | 330 |
330 | 331 |
331 void JSGenericLowering::LowerJSLoadContext(Node* node) { | 332 void JSGenericLowering::LowerJSLoadContext(Node* node) { |
332 ContextAccess access = OpParameter<ContextAccess>(node); | 333 ContextAccess access = OpParameter<ContextAccess>(node); |
333 // TODO(mstarzinger): Use simplified operators instead of machine operators | 334 // TODO(mstarzinger): Use simplified operators instead of machine operators |
334 // here so that load/store optimization can be applied afterwards. | 335 // here so that load/store optimization can be applied afterwards. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 395 |
395 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 396 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
396 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); | 397 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); |
397 int arity = OperatorProperties::GetValueInputCount(node->op()); | 398 int arity = OperatorProperties::GetValueInputCount(node->op()); |
398 ReplaceWithRuntimeCall(node, function, arity); | 399 ReplaceWithRuntimeCall(node, function, arity); |
399 } | 400 } |
400 | 401 |
401 } // namespace compiler | 402 } // namespace compiler |
402 } // namespace internal | 403 } // namespace internal |
403 } // namespace v8 | 404 } // namespace v8 |
OLD | NEW |