| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 274 } |
| 275 | 275 |
| 276 | 276 |
| 277 void JSGenericLowering::LowerJSLoadProperty(Node* node) { | 277 void JSGenericLowering::LowerJSLoadProperty(Node* node) { |
| 278 Callable callable = CodeFactory::KeyedLoadIC(isolate()); | 278 Callable callable = CodeFactory::KeyedLoadIC(isolate()); |
| 279 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 279 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); |
| 280 } | 280 } |
| 281 | 281 |
| 282 | 282 |
| 283 void JSGenericLowering::LowerJSLoadNamed(Node* node) { | 283 void JSGenericLowering::LowerJSLoadNamed(Node* node) { |
| 284 LoadNamedParameters p = OpParameter<LoadNamedParameters>(node); | 284 const LoadNamedParameters& p = LoadNamedParametersOf(node->op()); |
| 285 Callable callable = CodeFactory::LoadIC(isolate(), p.contextual_mode); | 285 Callable callable = CodeFactory::LoadIC(isolate(), p.contextual_mode()); |
| 286 PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name)); | 286 PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name())); |
| 287 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 287 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); |
| 288 } | 288 } |
| 289 | 289 |
| 290 | 290 |
| 291 void JSGenericLowering::LowerJSStoreProperty(Node* node) { | 291 void JSGenericLowering::LowerJSStoreProperty(Node* node) { |
| 292 StrictMode strict_mode = OpParameter<StrictMode>(node); | 292 StrictMode strict_mode = OpParameter<StrictMode>(node); |
| 293 Callable callable = CodeFactory::KeyedStoreIC(isolate(), strict_mode); | 293 Callable callable = CodeFactory::KeyedStoreIC(isolate(), strict_mode); |
| 294 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 294 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); |
| 295 } | 295 } |
| 296 | 296 |
| 297 | 297 |
| 298 void JSGenericLowering::LowerJSStoreNamed(Node* node) { | 298 void JSGenericLowering::LowerJSStoreNamed(Node* node) { |
| 299 StoreNamedParameters params = OpParameter<StoreNamedParameters>(node); | 299 const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); |
| 300 Callable callable = CodeFactory::StoreIC(isolate(), params.strict_mode); | 300 Callable callable = CodeFactory::StoreIC(isolate(), p.strict_mode()); |
| 301 PatchInsertInput(node, 1, jsgraph()->HeapConstant(params.name)); | 301 PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name())); |
| 302 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); | 302 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); |
| 303 } | 303 } |
| 304 | 304 |
| 305 | 305 |
| 306 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 306 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
| 307 StrictMode strict_mode = OpParameter<StrictMode>(node); | 307 StrictMode strict_mode = OpParameter<StrictMode>(node); |
| 308 PatchInsertInput(node, 2, SmiConstant(strict_mode)); | 308 PatchInsertInput(node, 2, SmiConstant(strict_mode)); |
| 309 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); | 309 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); |
| 310 } | 310 } |
| 311 | 311 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 = linkage()->GetStubCallDescriptor(d, 0); |
| 325 Node* stub_code = CodeConstant(stub.GetCode()); | 325 Node* stub_code = CodeConstant(stub.GetCode()); |
| 326 PatchInsertInput(node, 0, stub_code); | 326 PatchInsertInput(node, 0, stub_code); |
| 327 PatchOperator(node, common()->Call(desc)); | 327 PatchOperator(node, common()->Call(desc)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 | 330 |
| 331 void JSGenericLowering::LowerJSLoadContext(Node* node) { | 331 void JSGenericLowering::LowerJSLoadContext(Node* node) { |
| 332 ContextAccess access = OpParameter<ContextAccess>(node); | 332 const ContextAccess& access = ContextAccessOf(node->op()); |
| 333 // TODO(mstarzinger): Use simplified operators instead of machine operators | 333 // TODO(mstarzinger): Use simplified operators instead of machine operators |
| 334 // here so that load/store optimization can be applied afterwards. | 334 // here so that load/store optimization can be applied afterwards. |
| 335 for (int i = 0; i < access.depth(); ++i) { | 335 for (size_t i = 0; i < access.depth(); ++i) { |
| 336 node->ReplaceInput( | 336 node->ReplaceInput( |
| 337 0, graph()->NewNode( | 337 0, graph()->NewNode( |
| 338 machine()->Load(kMachAnyTagged), | 338 machine()->Load(kMachAnyTagged), |
| 339 NodeProperties::GetValueInput(node, 0), | 339 NodeProperties::GetValueInput(node, 0), |
| 340 Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), | 340 Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), |
| 341 NodeProperties::GetEffectInput(node))); | 341 NodeProperties::GetEffectInput(node))); |
| 342 } | 342 } |
| 343 node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); | 343 node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); |
| 344 PatchOperator(node, machine()->Load(kMachAnyTagged)); | 344 PatchOperator(node, machine()->Load(kMachAnyTagged)); |
| 345 } | 345 } |
| 346 | 346 |
| 347 | 347 |
| 348 void JSGenericLowering::LowerJSStoreContext(Node* node) { | 348 void JSGenericLowering::LowerJSStoreContext(Node* node) { |
| 349 ContextAccess access = OpParameter<ContextAccess>(node); | 349 const ContextAccess& access = ContextAccessOf(node->op()); |
| 350 // TODO(mstarzinger): Use simplified operators instead of machine operators | 350 // TODO(mstarzinger): Use simplified operators instead of machine operators |
| 351 // here so that load/store optimization can be applied afterwards. | 351 // here so that load/store optimization can be applied afterwards. |
| 352 for (int i = 0; i < access.depth(); ++i) { | 352 for (size_t i = 0; i < access.depth(); ++i) { |
| 353 node->ReplaceInput( | 353 node->ReplaceInput( |
| 354 0, graph()->NewNode( | 354 0, graph()->NewNode( |
| 355 machine()->Load(kMachAnyTagged), | 355 machine()->Load(kMachAnyTagged), |
| 356 NodeProperties::GetValueInput(node, 0), | 356 NodeProperties::GetValueInput(node, 0), |
| 357 Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), | 357 Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), |
| 358 NodeProperties::GetEffectInput(node))); | 358 NodeProperties::GetEffectInput(node))); |
| 359 } | 359 } |
| 360 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); | 360 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); |
| 361 node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); | 361 node->ReplaceInput(1, Int32Constant(Context::SlotOffset(access.index()))); |
| 362 PatchOperator(node, machine()->Store(StoreRepresentation(kMachAnyTagged, | 362 PatchOperator(node, machine()->Store(StoreRepresentation(kMachAnyTagged, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 374 Node* construct = NodeProperties::GetValueInput(node, 0); | 374 Node* construct = NodeProperties::GetValueInput(node, 0); |
| 375 PatchInsertInput(node, 0, stub_code); | 375 PatchInsertInput(node, 0, stub_code); |
| 376 PatchInsertInput(node, 1, Int32Constant(arity - 1)); | 376 PatchInsertInput(node, 1, Int32Constant(arity - 1)); |
| 377 PatchInsertInput(node, 2, construct); | 377 PatchInsertInput(node, 2, construct); |
| 378 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); | 378 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); |
| 379 PatchOperator(node, common()->Call(desc)); | 379 PatchOperator(node, common()->Call(desc)); |
| 380 } | 380 } |
| 381 | 381 |
| 382 | 382 |
| 383 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 383 void JSGenericLowering::LowerJSCallFunction(Node* node) { |
| 384 CallParameters p = OpParameter<CallParameters>(node); | 384 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); |
| 385 CallFunctionStub stub(isolate(), p.arity - 2, p.flags); | 385 CallFunctionStub stub(isolate(), static_cast<int>(p.arity() - 2), p.flags()); |
| 386 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 386 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |
| 387 CallDescriptor* desc = | 387 CallDescriptor* desc = linkage()->GetStubCallDescriptor( |
| 388 linkage()->GetStubCallDescriptor(d, p.arity - 1, FlagsForNode(node)); | 388 d, static_cast<int>(p.arity() - 1), FlagsForNode(node)); |
| 389 Node* stub_code = CodeConstant(stub.GetCode()); | 389 Node* stub_code = CodeConstant(stub.GetCode()); |
| 390 PatchInsertInput(node, 0, stub_code); | 390 PatchInsertInput(node, 0, stub_code); |
| 391 PatchOperator(node, common()->Call(desc)); | 391 PatchOperator(node, common()->Call(desc)); |
| 392 } | 392 } |
| 393 | 393 |
| 394 | 394 |
| 395 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 395 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
| 396 Runtime::FunctionId function = OpParameter<Runtime::FunctionId>(node); | 396 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
| 397 int arity = OperatorProperties::GetValueInputCount(node->op()); | 397 ReplaceWithRuntimeCall(node, p.id(), p.arity()); |
| 398 ReplaceWithRuntimeCall(node, function, arity); | |
| 399 } | 398 } |
| 400 | 399 |
| 401 } // namespace compiler | 400 } // namespace compiler |
| 402 } // namespace internal | 401 } // namespace internal |
| 403 } // namespace v8 | 402 } // namespace v8 |
| OLD | NEW |