OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/builtins.h" | 5 #include "src/builtins.h" |
6 | 6 |
7 #include "src/api-arguments.h" | 7 #include "src/api-arguments.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/base/ieee754.h" | 10 #include "src/base/ieee754.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // A builtin function is defined by writing: | 92 // A builtin function is defined by writing: |
93 // | 93 // |
94 // BUILTIN(name) { | 94 // BUILTIN(name) { |
95 // ... | 95 // ... |
96 // } | 96 // } |
97 // | 97 // |
98 // In the body of the builtin function the arguments can be accessed | 98 // In the body of the builtin function the arguments can be accessed |
99 // through the BuiltinArguments object args. | 99 // through the BuiltinArguments object args. |
100 // TODO(cbruni): add global flag to check whether any tracing events have been | 100 // TODO(cbruni): add global flag to check whether any tracing events have been |
101 // enabled. | 101 // enabled. |
102 #define BUILTIN(name) \ | 102 #define BUILTIN(name) \ |
103 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ | 103 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ |
104 Isolate* isolate); \ | 104 Isolate* isolate); \ |
105 \ | 105 \ |
106 V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \ | 106 V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \ |
107 int args_length, Object** args_object, Isolate* isolate) { \ | 107 int args_length, Object** args_object, Isolate* isolate) { \ |
108 BuiltinArguments args(args_length, args_object); \ | 108 BuiltinArguments args(args_length, args_object); \ |
109 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Builtin_##name); \ | 109 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Builtin_##name); \ |
110 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ | 110 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ |
111 "V8.Builtin_" #name); \ | 111 "V8.Builtin_" #name); \ |
112 return Builtin_Impl_##name(args, isolate); \ | 112 return Builtin_Impl_##name(args, isolate); \ |
113 } \ | 113 } \ |
114 \ | 114 \ |
115 MUST_USE_RESULT static Object* Builtin_##name( \ | 115 MUST_USE_RESULT static Object* Builtin_##name( \ |
116 int args_length, Object** args_object, Isolate* isolate) { \ | 116 int args_length, Object** args_object, Isolate* isolate) { \ |
117 if (FLAG_runtime_call_stats) { \ | 117 DCHECK(isolate->context() == nullptr || isolate->context()->IsContext()); \ |
118 return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ | 118 if (FLAG_runtime_call_stats) { \ |
119 } \ | 119 return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ |
120 BuiltinArguments args(args_length, args_object); \ | 120 } \ |
121 return Builtin_Impl_##name(args, isolate); \ | 121 BuiltinArguments args(args_length, args_object); \ |
122 } \ | 122 return Builtin_Impl_##name(args, isolate); \ |
123 \ | 123 } \ |
124 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ | 124 \ |
| 125 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ |
125 Isolate* isolate) | 126 Isolate* isolate) |
126 | 127 |
127 // ---------------------------------------------------------------------------- | 128 // ---------------------------------------------------------------------------- |
128 | 129 |
129 #define CHECK_RECEIVER(Type, name, method) \ | 130 #define CHECK_RECEIVER(Type, name, method) \ |
130 if (!args.receiver()->Is##Type()) { \ | 131 if (!args.receiver()->Is##Type()) { \ |
131 THROW_NEW_ERROR_RETURN_FAILURE( \ | 132 THROW_NEW_ERROR_RETURN_FAILURE( \ |
132 isolate, \ | 133 isolate, \ |
133 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ | 134 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ |
134 isolate->factory()->NewStringFromAsciiChecked(method), \ | 135 isolate->factory()->NewStringFromAsciiChecked(method), \ |
(...skipping 6602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6737 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 6738 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
6738 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 6739 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
6739 #undef DEFINE_BUILTIN_ACCESSOR_C | 6740 #undef DEFINE_BUILTIN_ACCESSOR_C |
6740 #undef DEFINE_BUILTIN_ACCESSOR_A | 6741 #undef DEFINE_BUILTIN_ACCESSOR_A |
6741 #undef DEFINE_BUILTIN_ACCESSOR_T | 6742 #undef DEFINE_BUILTIN_ACCESSOR_T |
6742 #undef DEFINE_BUILTIN_ACCESSOR_S | 6743 #undef DEFINE_BUILTIN_ACCESSOR_S |
6743 #undef DEFINE_BUILTIN_ACCESSOR_H | 6744 #undef DEFINE_BUILTIN_ACCESSOR_H |
6744 | 6745 |
6745 } // namespace internal | 6746 } // namespace internal |
6746 } // namespace v8 | 6747 } // namespace v8 |
OLD | NEW |