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/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/compilation-info.h" | 7 #include "src/compilation-info.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 public: | 2021 public: |
2022 OutOfLineTrap(CodeGenerator* gen, bool frame_elided, Instruction* instr) | 2022 OutOfLineTrap(CodeGenerator* gen, bool frame_elided, Instruction* instr) |
2023 : OutOfLineCode(gen), | 2023 : OutOfLineCode(gen), |
2024 frame_elided_(frame_elided), | 2024 frame_elided_(frame_elided), |
2025 instr_(instr), | 2025 instr_(instr), |
2026 gen_(gen) {} | 2026 gen_(gen) {} |
2027 | 2027 |
2028 void Generate() final { | 2028 void Generate() final { |
2029 PPCOperandConverter i(gen_, instr_); | 2029 PPCOperandConverter i(gen_, instr_); |
2030 | 2030 |
2031 Runtime::FunctionId trap_id = static_cast<Runtime::FunctionId>( | 2031 Builtins::Name trap_id = |
2032 i.InputInt32(instr_->InputCount() - 1)); | 2032 static_cast<Builtins::Name>(i.InputInt32(instr_->InputCount() - 1)); |
2033 bool old_has_frame = __ has_frame(); | 2033 bool old_has_frame = __ has_frame(); |
2034 if (frame_elided_) { | 2034 if (frame_elided_) { |
2035 __ set_has_frame(true); | 2035 __ set_has_frame(true); |
2036 __ EnterFrame(StackFrame::WASM_COMPILED, true); | 2036 __ EnterFrame(StackFrame::WASM_COMPILED, true); |
2037 } | 2037 } |
2038 GenerateCallToTrap(trap_id); | 2038 GenerateCallToTrap(trap_id); |
2039 if (frame_elided_) { | 2039 if (frame_elided_) { |
2040 __ set_has_frame(old_has_frame); | 2040 __ set_has_frame(old_has_frame); |
2041 } | 2041 } |
2042 } | 2042 } |
2043 | 2043 |
2044 private: | 2044 private: |
2045 void GenerateCallToTrap(Runtime::FunctionId trap_id) { | 2045 void GenerateCallToTrap(Builtins::Name trap_id) { |
2046 if (trap_id == Runtime::kNumFunctions) { | 2046 if (trap_id == Builtins::builtin_count) { |
2047 // We cannot test calls to the runtime in cctest/test-run-wasm. | 2047 // We cannot test calls to the runtime in cctest/test-run-wasm. |
2048 // Therefore we emit a call to C here instead of a call to the runtime. | 2048 // Therefore we emit a call to C here instead of a call to the runtime. |
2049 // We use the context register as the scratch register, because we do | 2049 // We use the context register as the scratch register, because we do |
2050 // not have a context here. | 2050 // not have a context here. |
2051 __ PrepareCallCFunction(0, 0, cp); | 2051 __ PrepareCallCFunction(0, 0, cp); |
2052 __ CallCFunction( | 2052 __ CallCFunction( |
2053 ExternalReference::wasm_call_trap_callback_for_testing(isolate()), | 2053 ExternalReference::wasm_call_trap_callback_for_testing(isolate()), |
2054 0); | 2054 0); |
2055 __ LeaveFrame(StackFrame::WASM_COMPILED); | 2055 __ LeaveFrame(StackFrame::WASM_COMPILED); |
2056 __ Ret(); | 2056 __ Ret(); |
2057 } else { | 2057 } else { |
2058 __ Move(cp, Smi::kZero); | |
2059 gen_->AssembleSourcePosition(instr_); | 2058 gen_->AssembleSourcePosition(instr_); |
2060 __ CallRuntime(trap_id); | 2059 __ Call(handle(isolate()->builtins()->builtin(trap_id), isolate()), |
| 2060 RelocInfo::CODE_TARGET); |
2061 ReferenceMap* reference_map = | 2061 ReferenceMap* reference_map = |
2062 new (gen_->zone()) ReferenceMap(gen_->zone()); | 2062 new (gen_->zone()) ReferenceMap(gen_->zone()); |
2063 gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0, | 2063 gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0, |
2064 Safepoint::kNoLazyDeopt); | 2064 Safepoint::kNoLazyDeopt); |
2065 if (FLAG_debug_code) { | 2065 if (FLAG_debug_code) { |
2066 __ stop(GetBailoutReason(kUnexpectedReturnFromWasmTrap)); | 2066 __ stop(GetBailoutReason(kUnexpectedReturnFromWasmTrap)); |
2067 } | 2067 } |
2068 } | 2068 } |
2069 } | 2069 } |
2070 | 2070 |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 padding_size -= v8::internal::Assembler::kInstrSize; | 2581 padding_size -= v8::internal::Assembler::kInstrSize; |
2582 } | 2582 } |
2583 } | 2583 } |
2584 } | 2584 } |
2585 | 2585 |
2586 #undef __ | 2586 #undef __ |
2587 | 2587 |
2588 } // namespace compiler | 2588 } // namespace compiler |
2589 } // namespace internal | 2589 } // namespace internal |
2590 } // namespace v8 | 2590 } // namespace v8 |
OLD | NEW |