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 3 // found in the LICENSE file. 4 5 #ifndef V8_INTERPRETER_INTERPRETER_INTRINSICS_H_ 6 #define V8_INTERPRETER_INTERPRETER_INTRINSICS_H_ 7 8 #include "src/runtime/runtime.h" 9 10 namespace v8 { 11 namespace internal { 12 namespace interpreter { 13 14 // List of supported intrisics, with upper case name, lower case name and 15 // expected number of arguments (-1 denoting argument count is variable). 16 #define INTRINSICS_LIST(V) \ 17 V(AsyncGeneratorReject, async_generator_reject, 2) \ 18 V(AsyncGeneratorResolve, async_generator_resolve, 3) \ 19 V(AsyncGeneratorYield, async_generator_yield, 3) \ 20 V(CreateJSGeneratorObject, create_js_generator_object, 2) \ 21 V(GeneratorGetResumeMode, generator_get_resume_mode, 1) \ 22 V(GeneratorGetInputOrDebugPos, generator_get_input_or_debug_pos, 1) \ 23 V(GeneratorClose, generator_close, 1) \ 24 V(GetImportMetaObject, get_import_meta_object, 0) \ 25 V(Call, call, -1) \ 26 V(CreateIterResultObject, create_iter_result_object, 2) \ 27 V(CreateAsyncFromSyncIterator, create_async_from_sync_iterator, 1) \ 28 V(HasProperty, has_property, 2) \ 29 V(GetProperty, get_property, 2) \ 30 V(IsArray, is_array, 1) \ 31 V(IsJSProxy, is_js_proxy, 1) \ 32 V(IsJSReceiver, is_js_receiver, 1) \ 33 V(IsSmi, is_smi, 1) \ 34 V(IsTypedArray, is_typed_array, 1) \ 35 V(RejectPromise, reject_promise, 3) \ 36 V(ResolvePromise, resolve_promise, 2) \ 37 V(ToString, to_string, 1) \ 38 V(ToLength, to_length, 1) \ 39 V(ToInteger, to_integer, 1) \ 40 V(ToNumber, to_number, 1) \ 41 V(ToObject, to_object, 1) 42 43 class IntrinsicsHelper { 44 public: 45 enum class IntrinsicId { 46 #define DECLARE_INTRINSIC_ID(name, lower_case, count) k##name, 47 INTRINSICS_LIST(DECLARE_INTRINSIC_ID) 48 #undef DECLARE_INTRINSIC_ID 49 kIdCount 50 }; 51 STATIC_ASSERT(static_cast<uint32_t>(IntrinsicId::kIdCount) <= kMaxUInt8); 52 53 static bool IsSupported(Runtime::FunctionId function_id); 54 static IntrinsicId FromRuntimeId(Runtime::FunctionId function_id); 55 static Runtime::FunctionId ToRuntimeId(IntrinsicId intrinsic_id); 56 57 private: 58 DISALLOW_IMPLICIT_CONSTRUCTORS(IntrinsicsHelper); 59 }; 60 61 } // namespace interpreter 62 } // namespace internal 63 } // namespace v8 64 65 #endif // V8_INTERPRETER_INTERPRETER_INTRINSICS_H_ 66