1 // Copyright 2020 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/builtins/builtins.h"
6 #include "src/deoptimizer/deoptimizer.h"
7
8 extern "C" {
9 void Builtins_InterpreterEnterAtBytecode();
10 void Builtins_InterpreterEnterAtNextBytecode();
11 void Builtins_ContinueToCodeStubBuiltinWithResult();
12 void Builtins_ContinueToCodeStubBuiltin();
13 void Builtins_ContinueToJavaScriptBuiltinWithResult();
14 void Builtins_ContinueToJavaScriptBuiltin();
15 void construct_stub_create_deopt_addr();
16 void construct_stub_invoke_deopt_addr();
17 void Builtins_BaselineOrInterpreterEnterAtBytecode();
18 void Builtins_BaselineOrInterpreterEnterAtNextBytecode();
19 typedef void (*function_ptr)();
20 }
21
22 namespace v8 {
23 namespace internal {
24
25 // List of allowed builtin addresses that we can return to in the deoptimizer.
26 constexpr function_ptr builtins[] = {
27 &Builtins_InterpreterEnterAtBytecode,
28 &Builtins_InterpreterEnterAtNextBytecode,
29 &Builtins_ContinueToCodeStubBuiltinWithResult,
30 &Builtins_ContinueToCodeStubBuiltin,
31 &Builtins_ContinueToJavaScriptBuiltinWithResult,
32 &Builtins_ContinueToJavaScriptBuiltin,
33 &construct_stub_create_deopt_addr,
34 &construct_stub_invoke_deopt_addr,
35 &Builtins_BaselineOrInterpreterEnterAtBytecode,
36 &Builtins_BaselineOrInterpreterEnterAtNextBytecode,
37 };
38
IsValidReturnAddress(Address address)39 bool Deoptimizer::IsValidReturnAddress(Address address) {
40 for (function_ptr builtin : builtins) {
41 if (address == FUNCTION_ADDR(builtin)) {
42 return true;
43 }
44 }
45 return false;
46 }
47
48 } // namespace internal
49 } // namespace v8
50