| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 | 10 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 400 } |
| 401 | 401 |
| 402 Node* WasmGraphBuilder::Int32Constant(int32_t value) { | 402 Node* WasmGraphBuilder::Int32Constant(int32_t value) { |
| 403 return jsgraph()->Int32Constant(value); | 403 return jsgraph()->Int32Constant(value); |
| 404 } | 404 } |
| 405 | 405 |
| 406 Node* WasmGraphBuilder::Int64Constant(int64_t value) { | 406 Node* WasmGraphBuilder::Int64Constant(int64_t value) { |
| 407 return jsgraph()->Int64Constant(value); | 407 return jsgraph()->Int64Constant(value); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void WasmGraphBuilder::StackCheck(wasm::WasmCodePosition position) { | 410 void WasmGraphBuilder::StackCheck(wasm::WasmCodePosition position, |
| 411 Node** effect, Node** control) { |
| 412 if (effect == nullptr) { |
| 413 effect = effect_; |
| 414 } |
| 415 if (control == nullptr) { |
| 416 control = control_; |
| 417 } |
| 411 // We do not generate stack checks for cctests. | 418 // We do not generate stack checks for cctests. |
| 412 if (module_ && !module_->instance->context.is_null()) { | 419 if (module_ && !module_->instance->context.is_null()) { |
| 413 Node* limit = graph()->NewNode( | 420 Node* limit = graph()->NewNode( |
| 414 jsgraph()->machine()->Load(MachineType::Pointer()), | 421 jsgraph()->machine()->Load(MachineType::Pointer()), |
| 415 jsgraph()->ExternalConstant( | 422 jsgraph()->ExternalConstant( |
| 416 ExternalReference::address_of_stack_limit(jsgraph()->isolate())), | 423 ExternalReference::address_of_stack_limit(jsgraph()->isolate())), |
| 417 jsgraph()->IntPtrConstant(0), *effect_, *control_); | 424 jsgraph()->IntPtrConstant(0), *effect, *control); |
| 418 Node* pointer = graph()->NewNode(jsgraph()->machine()->LoadStackPointer()); | 425 Node* pointer = graph()->NewNode(jsgraph()->machine()->LoadStackPointer()); |
| 419 | 426 |
| 420 Node* check = | 427 Node* check = |
| 421 graph()->NewNode(jsgraph()->machine()->UintLessThan(), limit, pointer); | 428 graph()->NewNode(jsgraph()->machine()->UintLessThan(), limit, pointer); |
| 422 | 429 |
| 423 Diamond stack_check(graph(), jsgraph()->common(), check, BranchHint::kTrue); | 430 Diamond stack_check(graph(), jsgraph()->common(), check, BranchHint::kTrue); |
| 424 | 431 stack_check.Chain(*control); |
| 425 Node* effect_true = *effect_; | 432 Node* effect_true = *effect; |
| 426 | 433 |
| 427 Node* effect_false; | 434 Node* effect_false; |
| 428 // Generate a call to the runtime if there is a stack check failure. | 435 // Generate a call to the runtime if there is a stack check failure. |
| 429 { | 436 { |
| 430 Node* node = BuildCallToRuntime(Runtime::kStackGuard, jsgraph(), | 437 Node* node = BuildCallToRuntime(Runtime::kStackGuard, jsgraph(), |
| 431 module_->instance->context, nullptr, 0, | 438 module_->instance->context, nullptr, 0, |
| 432 effect_, stack_check.if_false); | 439 effect, stack_check.if_false); |
| 433 effect_false = node; | 440 effect_false = node; |
| 434 } | 441 } |
| 435 | 442 |
| 436 Node* ephi = graph()->NewNode(jsgraph()->common()->EffectPhi(2), | 443 Node* ephi = graph()->NewNode(jsgraph()->common()->EffectPhi(2), |
| 437 effect_true, effect_false, stack_check.merge); | 444 effect_true, effect_false, stack_check.merge); |
| 438 | 445 |
| 439 *control_ = stack_check.merge; | 446 *control = stack_check.merge; |
| 440 *effect_ = ephi; | 447 *effect = ephi; |
| 441 } | 448 } |
| 442 } | 449 } |
| 443 | 450 |
| 444 Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right, | 451 Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right, |
| 445 wasm::WasmCodePosition position) { | 452 wasm::WasmCodePosition position) { |
| 446 const Operator* op; | 453 const Operator* op; |
| 447 MachineOperatorBuilder* m = jsgraph()->machine(); | 454 MachineOperatorBuilder* m = jsgraph()->machine(); |
| 448 switch (opcode) { | 455 switch (opcode) { |
| 449 case wasm::kExprI32Add: | 456 case wasm::kExprI32Add: |
| 450 op = m->Int32Add(); | 457 op = m->Int32Add(); |
| (...skipping 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3409 function_->code_start_offset), | 3416 function_->code_start_offset), |
| 3410 compile_ms); | 3417 compile_ms); |
| 3411 } | 3418 } |
| 3412 | 3419 |
| 3413 return code; | 3420 return code; |
| 3414 } | 3421 } |
| 3415 | 3422 |
| 3416 } // namespace compiler | 3423 } // namespace compiler |
| 3417 } // namespace internal | 3424 } // namespace internal |
| 3418 } // namespace v8 | 3425 } // namespace v8 |
| OLD | NEW |