| 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.h" | 7 #include "src/api.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/api-natives.h" | 9 #include "src/api-natives.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // ---------------------------------------------------------------------------- | 131 // ---------------------------------------------------------------------------- |
| 132 // | 132 // |
| 133 // A builtin function is defined by writing: | 133 // A builtin function is defined by writing: |
| 134 // | 134 // |
| 135 // BUILTIN(name) { | 135 // BUILTIN(name) { |
| 136 // ... | 136 // ... |
| 137 // } | 137 // } |
| 138 // | 138 // |
| 139 // In the body of the builtin function the arguments can be accessed | 139 // In the body of the builtin function the arguments can be accessed |
| 140 // through the BuiltinArguments object args. | 140 // through the BuiltinArguments object args. |
| 141 | 141 // TODO(cbruni): add global flag to check whether any tracing events have been |
| 142 // enabled. |
| 142 #define BUILTIN(name) \ | 143 #define BUILTIN(name) \ |
| 143 MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \ | 144 MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \ |
| 144 Isolate* isolate); \ | 145 Isolate* isolate); \ |
| 146 \ |
| 147 V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \ |
| 148 int args_length, Object** args_object, Isolate* isolate) { \ |
| 149 name##ArgumentsType args(args_length, args_object); \ |
| 150 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \ |
| 151 RuntimeCallTimerScope timer(isolate, &stats->Builtin_##name); \ |
| 152 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ |
| 153 "V8.Builtin_" #name); \ |
| 154 return Builtin_Impl_##name(args, isolate); \ |
| 155 } \ |
| 156 \ |
| 145 MUST_USE_RESULT static Object* Builtin_##name( \ | 157 MUST_USE_RESULT static Object* Builtin_##name( \ |
| 146 int args_length, Object** args_object, Isolate* isolate) { \ | 158 int args_length, Object** args_object, Isolate* isolate) { \ |
| 147 Object* value; \ | 159 if (FLAG_runtime_call_stats) { \ |
| 148 isolate->counters()->runtime_calls()->Increment(); \ | 160 return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ |
| 149 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ | 161 } \ |
| 150 "V8.Builtin_" #name); \ | |
| 151 name##ArgumentsType args(args_length, args_object); \ | 162 name##ArgumentsType args(args_length, args_object); \ |
| 152 if (FLAG_runtime_call_stats) { \ | 163 return Builtin_Impl_##name(args, isolate); \ |
| 153 RuntimeCallStats* stats = isolate->counters()->runtime_call_stats(); \ | |
| 154 RuntimeCallTimerScope timer(isolate, &stats->Builtin_##name); \ | |
| 155 value = Builtin_Impl_##name(args, isolate); \ | |
| 156 } else { \ | |
| 157 value = Builtin_Impl_##name(args, isolate); \ | |
| 158 } \ | |
| 159 return value; \ | |
| 160 } \ | 164 } \ |
| 161 \ | 165 \ |
| 162 MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \ | 166 MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \ |
| 163 Isolate* isolate) | 167 Isolate* isolate) |
| 164 | 168 |
| 165 // ---------------------------------------------------------------------------- | 169 // ---------------------------------------------------------------------------- |
| 166 | 170 |
| 167 | |
| 168 #define CHECK_RECEIVER(Type, name, method) \ | 171 #define CHECK_RECEIVER(Type, name, method) \ |
| 169 if (!args.receiver()->Is##Type()) { \ | 172 if (!args.receiver()->Is##Type()) { \ |
| 170 THROW_NEW_ERROR_RETURN_FAILURE( \ | 173 THROW_NEW_ERROR_RETURN_FAILURE( \ |
| 171 isolate, \ | 174 isolate, \ |
| 172 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ | 175 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ |
| 173 isolate->factory()->NewStringFromAsciiChecked(method), \ | 176 isolate->factory()->NewStringFromAsciiChecked(method), \ |
| 174 args.receiver())); \ | 177 args.receiver())); \ |
| 175 } \ | 178 } \ |
| 176 Handle<Type> name = Handle<Type>::cast(args.receiver()) | 179 Handle<Type> name = Handle<Type>::cast(args.receiver()) |
| 177 | 180 |
| (...skipping 4764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4942 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) | 4945 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) |
| 4943 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4946 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4944 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4947 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4945 #undef DEFINE_BUILTIN_ACCESSOR_C | 4948 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4946 #undef DEFINE_BUILTIN_ACCESSOR_A | 4949 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4947 #undef DEFINE_BUILTIN_ACCESSOR_T | 4950 #undef DEFINE_BUILTIN_ACCESSOR_T |
| 4948 #undef DEFINE_BUILTIN_ACCESSOR_H | 4951 #undef DEFINE_BUILTIN_ACCESSOR_H |
| 4949 | 4952 |
| 4950 } // namespace internal | 4953 } // namespace internal |
| 4951 } // namespace v8 | 4954 } // namespace v8 |
| OLD | NEW |