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 #ifndef V8_INTERPRETER_INTERPRETER_INTRINSICS_H_ | 5 #ifndef V8_INTERPRETER_INTERPRETER_INTRINSICS_H_ |
6 #define V8_INTERPRETER_INTERPRETER_INTRINSICS_H_ | 6 #define V8_INTERPRETER_INTERPRETER_INTRINSICS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/base/smart-pointers.h" | 9 #include "src/base/smart-pointers.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
11 #include "src/frames.h" | 11 #include "src/frames.h" |
12 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
13 #include "src/interpreter/interpreter-assembler.h" | 13 #include "src/interpreter/interpreter-assembler.h" |
14 #include "src/runtime/runtime.h" | 14 #include "src/runtime/runtime.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 namespace compiler { | 19 namespace compiler { |
20 class Node; | 20 class Node; |
21 } // namespace compiler | 21 } // namespace compiler |
22 | 22 |
| 23 // List of supported intrisics, with upper case name, lower case name and |
| 24 // expected number of arguments (-1 denoting argument count is variable). |
23 #define INTRINSICS_LIST(V) \ | 25 #define INTRINSICS_LIST(V) \ |
| 26 V(Call, call, -1) \ |
24 V(IsJSReceiver, is_js_receiver, 1) \ | 27 V(IsJSReceiver, is_js_receiver, 1) \ |
25 V(IsArray, is_array, 1) | 28 V(IsArray, is_array, 1) |
26 | 29 |
27 namespace interpreter { | 30 namespace interpreter { |
28 | 31 |
29 class IntrinsicsHelper { | 32 class IntrinsicsHelper { |
30 public: | 33 public: |
31 explicit IntrinsicsHelper(InterpreterAssembler* assembler); | 34 explicit IntrinsicsHelper(InterpreterAssembler* assembler); |
32 | 35 |
33 compiler::Node* InvokeIntrinsic(compiler::Node* function_id, | 36 compiler::Node* InvokeIntrinsic(compiler::Node* function_id, |
34 compiler::Node* context, | 37 compiler::Node* context, |
35 compiler::Node* first_arg_reg, | 38 compiler::Node* first_arg_reg, |
36 compiler::Node* arg_count); | 39 compiler::Node* arg_count); |
37 | 40 |
38 static bool IsSupported(Runtime::FunctionId function_id); | 41 static bool IsSupported(Runtime::FunctionId function_id); |
39 | 42 |
40 private: | 43 private: |
41 enum InstanceTypeCompareMode { | 44 enum InstanceTypeCompareMode { |
42 kInstanceTypeEqual, | 45 kInstanceTypeEqual, |
43 kInstanceTypeGreaterThanOrEqual | 46 kInstanceTypeGreaterThanOrEqual |
44 }; | 47 }; |
45 compiler::Node* CompareInstanceType(compiler::Node* map, int type, | 48 compiler::Node* CompareInstanceType(compiler::Node* map, int type, |
46 InstanceTypeCompareMode mode); | 49 InstanceTypeCompareMode mode); |
47 void AbortIfArgCountMismatch(int expected, compiler::Node* actual); | 50 void AbortIfArgCountMismatch(int expected, compiler::Node* actual); |
48 InterpreterAssembler* assembler_; | 51 InterpreterAssembler* assembler_; |
49 | 52 |
50 #define DECLARE_INTRINSIC_HELPER(name, lower_case, count) \ | 53 #define DECLARE_INTRINSIC_HELPER(name, lower_case, count) \ |
51 compiler::Node* name(compiler::Node* input); | 54 compiler::Node* name(compiler::Node* input, compiler::Node* arg_count, \ |
| 55 compiler::Node* context); |
52 INTRINSICS_LIST(DECLARE_INTRINSIC_HELPER) | 56 INTRINSICS_LIST(DECLARE_INTRINSIC_HELPER) |
53 #undef DECLARE_INTRINSIC_HELPER | 57 #undef DECLARE_INTRINSIC_HELPER |
54 | 58 |
55 DISALLOW_COPY_AND_ASSIGN(IntrinsicsHelper); | 59 DISALLOW_COPY_AND_ASSIGN(IntrinsicsHelper); |
56 }; | 60 }; |
57 | 61 |
58 } // namespace interpreter | 62 } // namespace interpreter |
59 } // namespace internal | 63 } // namespace internal |
60 } // namespace v8 | 64 } // namespace v8 |
61 | 65 |
62 #endif | 66 #endif |
OLD | NEW |