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/builtins.h" | 5 #include "src/builtins/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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // A builtin function is defined by writing: | 90 // A builtin function is defined by writing: |
91 // | 91 // |
92 // BUILTIN(name) { | 92 // BUILTIN(name) { |
93 // ... | 93 // ... |
94 // } | 94 // } |
95 // | 95 // |
96 // In the body of the builtin function the arguments can be accessed | 96 // In the body of the builtin function the arguments can be accessed |
97 // through the BuiltinArguments object args. | 97 // through the BuiltinArguments object args. |
98 // TODO(cbruni): add global flag to check whether any tracing events have been | 98 // TODO(cbruni): add global flag to check whether any tracing events have been |
99 // enabled. | 99 // enabled. |
100 #define BUILTIN(name) \ | 100 #define BUILTIN(name) \ |
101 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ | 101 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ |
102 Isolate* isolate); \ | 102 Isolate* isolate); \ |
103 \ | 103 \ |
104 V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \ | 104 V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \ |
105 int args_length, Object** args_object, Isolate* isolate) { \ | 105 int args_length, Object** args_object, Isolate* isolate) { \ |
106 BuiltinArguments args(args_length, args_object); \ | 106 BuiltinArguments args(args_length, args_object); \ |
107 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Builtin_##name); \ | 107 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Builtin_##name); \ |
108 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ | 108 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ |
109 "V8.Builtin_" #name); \ | 109 "V8.Builtin_" #name); \ |
110 return Builtin_Impl_##name(args, isolate); \ | 110 return Builtin_Impl_##name(args, isolate); \ |
111 } \ | 111 } \ |
112 \ | 112 \ |
113 MUST_USE_RESULT static Object* Builtin_##name( \ | 113 MUST_USE_RESULT static Object* Builtin_##name( \ |
114 int args_length, Object** args_object, Isolate* isolate) { \ | 114 int args_length, Object** args_object, Isolate* isolate) { \ |
115 if (FLAG_runtime_call_stats) { \ | 115 DCHECK(isolate->context() == nullptr || isolate->context()->IsContext()); \ |
116 return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ | 116 if (FLAG_runtime_call_stats) { \ |
117 } \ | 117 return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ |
118 BuiltinArguments args(args_length, args_object); \ | 118 } \ |
119 return Builtin_Impl_##name(args, isolate); \ | 119 BuiltinArguments args(args_length, args_object); \ |
120 } \ | 120 return Builtin_Impl_##name(args, isolate); \ |
121 \ | 121 } \ |
122 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ | 122 \ |
| 123 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ |
123 Isolate* isolate) | 124 Isolate* isolate) |
124 | 125 |
125 // ---------------------------------------------------------------------------- | 126 // ---------------------------------------------------------------------------- |
126 | 127 |
127 #define CHECK_RECEIVER(Type, name, method) \ | 128 #define CHECK_RECEIVER(Type, name, method) \ |
128 if (!args.receiver()->Is##Type()) { \ | 129 if (!args.receiver()->Is##Type()) { \ |
129 THROW_NEW_ERROR_RETURN_FAILURE( \ | 130 THROW_NEW_ERROR_RETURN_FAILURE( \ |
130 isolate, \ | 131 isolate, \ |
131 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ | 132 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ |
132 isolate->factory()->NewStringFromAsciiChecked(method), \ | 133 isolate->factory()->NewStringFromAsciiChecked(method), \ |
(...skipping 6529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6662 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 6663 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
6663 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 6664 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
6664 #undef DEFINE_BUILTIN_ACCESSOR_C | 6665 #undef DEFINE_BUILTIN_ACCESSOR_C |
6665 #undef DEFINE_BUILTIN_ACCESSOR_A | 6666 #undef DEFINE_BUILTIN_ACCESSOR_A |
6666 #undef DEFINE_BUILTIN_ACCESSOR_T | 6667 #undef DEFINE_BUILTIN_ACCESSOR_T |
6667 #undef DEFINE_BUILTIN_ACCESSOR_S | 6668 #undef DEFINE_BUILTIN_ACCESSOR_S |
6668 #undef DEFINE_BUILTIN_ACCESSOR_H | 6669 #undef DEFINE_BUILTIN_ACCESSOR_H |
6669 | 6670 |
6670 } // namespace internal | 6671 } // namespace internal |
6671 } // namespace v8 | 6672 } // namespace v8 |
OLD | NEW |