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 16 matching lines...) Expand all Loading... |
27 #include "src/string-builder.h" | 27 #include "src/string-builder.h" |
28 #include "src/uri.h" | 28 #include "src/uri.h" |
29 #include "src/vm-state-inl.h" | 29 #include "src/vm-state-inl.h" |
30 | 30 |
31 namespace v8 { | 31 namespace v8 { |
32 namespace internal { | 32 namespace internal { |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 // Arguments object passed to C++ builtins. | 36 // Arguments object passed to C++ builtins. |
37 template <BuiltinExtraArguments extra_args> | |
38 class BuiltinArguments : public Arguments { | 37 class BuiltinArguments : public Arguments { |
39 public: | 38 public: |
40 BuiltinArguments(int length, Object** arguments) | 39 BuiltinArguments(int length, Object** arguments) |
41 : Arguments(length, arguments) { | 40 : Arguments(length, arguments) { |
42 // Check we have at least the receiver. | 41 // Check we have at least the receiver. |
43 DCHECK_LE(1, this->length()); | 42 DCHECK_LE(1, this->length()); |
44 } | 43 } |
45 | 44 |
46 Object*& operator[] (int index) { | 45 Object*& operator[] (int index) { |
47 DCHECK_LT(index, length()); | 46 DCHECK_LT(index, length()); |
(...skipping 10 matching lines...) Expand all Loading... |
58 return isolate->factory()->undefined_value(); | 57 return isolate->factory()->undefined_value(); |
59 } | 58 } |
60 return at<Object>(index); | 59 return at<Object>(index); |
61 } | 60 } |
62 | 61 |
63 Handle<Object> receiver() { | 62 Handle<Object> receiver() { |
64 return Arguments::at<Object>(0); | 63 return Arguments::at<Object>(0); |
65 } | 64 } |
66 | 65 |
67 template <class S> | 66 template <class S> |
68 Handle<S> target(); | 67 Handle<S> target() { |
69 Handle<HeapObject> new_target(); | 68 return Arguments::at<S>(Arguments::length() - 2); |
| 69 } |
| 70 Handle<HeapObject> new_target() { |
| 71 return Arguments::at<HeapObject>(Arguments::length() - 1); |
| 72 } |
70 | 73 |
71 // Gets the total number of arguments including the receiver (but | 74 // Gets the total number of arguments including the receiver (but |
72 // excluding extra arguments). | 75 // excluding extra arguments). |
73 int length() const; | 76 int length() const { return Arguments::length() - 2; } |
74 }; | 77 }; |
75 | 78 |
76 | 79 |
77 // Specialize BuiltinArguments for the extra arguments. | |
78 | |
79 template <> | |
80 int BuiltinArguments<BuiltinExtraArguments::kNone>::length() const { | |
81 return Arguments::length(); | |
82 } | |
83 | |
84 template <> | |
85 int BuiltinArguments<BuiltinExtraArguments::kTarget>::length() const { | |
86 return Arguments::length() - 1; | |
87 } | |
88 | |
89 template <> | |
90 template <class S> | |
91 Handle<S> BuiltinArguments<BuiltinExtraArguments::kTarget>::target() { | |
92 return Arguments::at<S>(Arguments::length() - 1); | |
93 } | |
94 | |
95 template <> | |
96 int BuiltinArguments<BuiltinExtraArguments::kNewTarget>::length() const { | |
97 return Arguments::length() - 1; | |
98 } | |
99 | |
100 template <> | |
101 Handle<HeapObject> | |
102 BuiltinArguments<BuiltinExtraArguments::kNewTarget>::new_target() { | |
103 return Arguments::at<HeapObject>(Arguments::length() - 1); | |
104 } | |
105 | |
106 template <> | |
107 int BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>::length() | |
108 const { | |
109 return Arguments::length() - 2; | |
110 } | |
111 | |
112 template <> | |
113 template <class S> | |
114 Handle<S> | |
115 BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>::target() { | |
116 return Arguments::at<S>(Arguments::length() - 2); | |
117 } | |
118 | |
119 template <> | |
120 Handle<HeapObject> | |
121 BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>::new_target() { | |
122 return Arguments::at<HeapObject>(Arguments::length() - 1); | |
123 } | |
124 | |
125 | |
126 #define DEF_ARG_TYPE(name, spec) \ | |
127 typedef BuiltinArguments<BuiltinExtraArguments::spec> name##ArgumentsType; | |
128 BUILTIN_LIST_C(DEF_ARG_TYPE) | |
129 #undef DEF_ARG_TYPE | |
130 | |
131 | |
132 // ---------------------------------------------------------------------------- | 80 // ---------------------------------------------------------------------------- |
133 // Support macro for defining builtins in C++. | 81 // Support macro for defining builtins in C++. |
134 // ---------------------------------------------------------------------------- | 82 // ---------------------------------------------------------------------------- |
135 // | 83 // |
136 // A builtin function is defined by writing: | 84 // A builtin function is defined by writing: |
137 // | 85 // |
138 // BUILTIN(name) { | 86 // BUILTIN(name) { |
139 // ... | 87 // ... |
140 // } | 88 // } |
141 // | 89 // |
142 // In the body of the builtin function the arguments can be accessed | 90 // In the body of the builtin function the arguments can be accessed |
143 // through the BuiltinArguments object args. | 91 // through the BuiltinArguments object args. |
144 // TODO(cbruni): add global flag to check whether any tracing events have been | 92 // TODO(cbruni): add global flag to check whether any tracing events have been |
145 // enabled. | 93 // enabled. |
146 #define BUILTIN(name) \ | 94 #define BUILTIN(name) \ |
147 MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \ | 95 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ |
148 Isolate* isolate); \ | 96 Isolate* isolate); \ |
149 \ | 97 \ |
150 V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \ | 98 V8_NOINLINE static Object* Builtin_Impl_Stats_##name( \ |
151 int args_length, Object** args_object, Isolate* isolate) { \ | 99 int args_length, Object** args_object, Isolate* isolate) { \ |
152 name##ArgumentsType args(args_length, args_object); \ | 100 BuiltinArguments args(args_length, args_object); \ |
153 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Builtin_##name); \ | 101 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Builtin_##name); \ |
154 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ | 102 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.runtime"), \ |
155 "V8.Builtin_" #name); \ | 103 "V8.Builtin_" #name); \ |
156 return Builtin_Impl_##name(args, isolate); \ | 104 return Builtin_Impl_##name(args, isolate); \ |
157 } \ | 105 } \ |
158 \ | 106 \ |
159 MUST_USE_RESULT static Object* Builtin_##name( \ | 107 MUST_USE_RESULT static Object* Builtin_##name( \ |
160 int args_length, Object** args_object, Isolate* isolate) { \ | 108 int args_length, Object** args_object, Isolate* isolate) { \ |
161 if (FLAG_runtime_call_stats) { \ | 109 if (FLAG_runtime_call_stats) { \ |
162 return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ | 110 return Builtin_Impl_Stats_##name(args_length, args_object, isolate); \ |
163 } \ | 111 } \ |
164 name##ArgumentsType args(args_length, args_object); \ | 112 BuiltinArguments args(args_length, args_object); \ |
165 return Builtin_Impl_##name(args, isolate); \ | 113 return Builtin_Impl_##name(args, isolate); \ |
166 } \ | 114 } \ |
167 \ | 115 \ |
168 MUST_USE_RESULT static Object* Builtin_Impl_##name(name##ArgumentsType args, \ | 116 MUST_USE_RESULT static Object* Builtin_Impl_##name(BuiltinArguments args, \ |
169 Isolate* isolate) | 117 Isolate* isolate) |
170 | 118 |
171 // ---------------------------------------------------------------------------- | 119 // ---------------------------------------------------------------------------- |
172 | 120 |
173 #define CHECK_RECEIVER(Type, name, method) \ | 121 #define CHECK_RECEIVER(Type, name, method) \ |
174 if (!args.receiver()->Is##Type()) { \ | 122 if (!args.receiver()->Is##Type()) { \ |
175 THROW_NEW_ERROR_RETURN_FAILURE( \ | 123 THROW_NEW_ERROR_RETURN_FAILURE( \ |
176 isolate, \ | 124 isolate, \ |
177 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ | 125 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, \ |
178 isolate->factory()->NewStringFromAsciiChecked(method), \ | 126 isolate->factory()->NewStringFromAsciiChecked(method), \ |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 JSObject* current = iter.GetCurrent<JSObject>(); | 227 JSObject* current = iter.GetCurrent<JSObject>(); |
280 if (!HasSimpleElements(current)) return false; | 228 if (!HasSimpleElements(current)) return false; |
281 } | 229 } |
282 return true; | 230 return true; |
283 } | 231 } |
284 | 232 |
285 // Returns |false| if not applicable. | 233 // Returns |false| if not applicable. |
286 MUST_USE_RESULT | 234 MUST_USE_RESULT |
287 inline bool EnsureJSArrayWithWritableFastElements(Isolate* isolate, | 235 inline bool EnsureJSArrayWithWritableFastElements(Isolate* isolate, |
288 Handle<Object> receiver, | 236 Handle<Object> receiver, |
289 Arguments* args, | 237 BuiltinArguments* args, |
290 int first_added_arg) { | 238 int first_added_arg) { |
291 if (!receiver->IsJSArray()) return false; | 239 if (!receiver->IsJSArray()) return false; |
292 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 240 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
293 ElementsKind origin_kind = array->GetElementsKind(); | 241 ElementsKind origin_kind = array->GetElementsKind(); |
294 if (IsDictionaryElementsKind(origin_kind)) return false; | 242 if (IsDictionaryElementsKind(origin_kind)) return false; |
295 if (!array->map()->is_extensible()) return false; | 243 if (!array->map()->is_extensible()) return false; |
296 if (args == nullptr) return true; | 244 if (args == nullptr) return true; |
297 | 245 |
298 // If there may be elements accessors in the prototype chain, the fast path | 246 // If there may be elements accessors in the prototype chain, the fast path |
299 // cannot be used if there arguments to add to the array. | 247 // cannot be used if there arguments to add to the array. |
(...skipping 26 matching lines...) Expand all Loading... |
326 } | 274 } |
327 if (target_kind != origin_kind) { | 275 if (target_kind != origin_kind) { |
328 // Use a short-lived HandleScope to avoid creating several copies of the | 276 // Use a short-lived HandleScope to avoid creating several copies of the |
329 // elements handle which would cause issues when left-trimming later-on. | 277 // elements handle which would cause issues when left-trimming later-on. |
330 HandleScope scope(isolate); | 278 HandleScope scope(isolate); |
331 JSObject::TransitionElementsKind(array, target_kind); | 279 JSObject::TransitionElementsKind(array, target_kind); |
332 } | 280 } |
333 return true; | 281 return true; |
334 } | 282 } |
335 | 283 |
336 | 284 MUST_USE_RESULT static Object* CallJsIntrinsic(Isolate* isolate, |
337 MUST_USE_RESULT static Object* CallJsIntrinsic( | 285 Handle<JSFunction> function, |
338 Isolate* isolate, Handle<JSFunction> function, | 286 BuiltinArguments args) { |
339 BuiltinArguments<BuiltinExtraArguments::kNone> args) { | |
340 HandleScope handleScope(isolate); | 287 HandleScope handleScope(isolate); |
341 int argc = args.length() - 1; | 288 int argc = args.length() - 1; |
342 ScopedVector<Handle<Object> > argv(argc); | 289 ScopedVector<Handle<Object> > argv(argc); |
343 for (int i = 0; i < argc; ++i) { | 290 for (int i = 0; i < argc; ++i) { |
344 argv[i] = args.at<Object>(i + 1); | 291 argv[i] = args.at<Object>(i + 1); |
345 } | 292 } |
346 RETURN_RESULT_OR_FAILURE( | 293 RETURN_RESULT_OR_FAILURE( |
347 isolate, | 294 isolate, |
348 Execution::Call(isolate, function, args.receiver(), argc, argv.start())); | 295 Execution::Call(isolate, function, args.receiver(), argc, argv.start())); |
349 } | 296 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 assembler->Bind(&return_false); | 381 assembler->Bind(&return_false); |
435 assembler->Return(assembler->BooleanConstant(false)); | 382 assembler->Return(assembler->BooleanConstant(false)); |
436 | 383 |
437 assembler->Bind(&call_runtime); | 384 assembler->Bind(&call_runtime); |
438 assembler->Return(assembler->CallRuntime(Runtime::kObjectHasOwnProperty, | 385 assembler->Return(assembler->CallRuntime(Runtime::kObjectHasOwnProperty, |
439 context, object, key)); | 386 context, object, key)); |
440 } | 387 } |
441 | 388 |
442 namespace { | 389 namespace { |
443 | 390 |
444 Object* DoArrayPush(Isolate* isolate, | 391 Object* DoArrayPush(Isolate* isolate, BuiltinArguments args) { |
445 BuiltinArguments<BuiltinExtraArguments::kNone> args) { | |
446 HandleScope scope(isolate); | 392 HandleScope scope(isolate); |
447 Handle<Object> receiver = args.receiver(); | 393 Handle<Object> receiver = args.receiver(); |
448 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1)) { | 394 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1)) { |
449 return CallJsIntrinsic(isolate, isolate->array_push(), args); | 395 return CallJsIntrinsic(isolate, isolate->array_push(), args); |
450 } | 396 } |
451 // Fast Elements Path | 397 // Fast Elements Path |
452 int to_add = args.length() - 1; | 398 int to_add = args.length() - 1; |
453 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 399 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
454 int len = Smi::cast(array->length())->value(); | 400 int len = Smi::cast(array->length())->value(); |
455 if (to_add == 0) return Smi::FromInt(len); | 401 if (to_add == 0) return Smi::FromInt(len); |
(...skipping 13 matching lines...) Expand all Loading... |
469 } // namespace | 415 } // namespace |
470 | 416 |
471 BUILTIN(ArrayPush) { return DoArrayPush(isolate, args); } | 417 BUILTIN(ArrayPush) { return DoArrayPush(isolate, args); } |
472 | 418 |
473 // TODO(verwaest): This is a temporary helper until the FastArrayPush stub can | 419 // TODO(verwaest): This is a temporary helper until the FastArrayPush stub can |
474 // tailcall to the builtin directly. | 420 // tailcall to the builtin directly. |
475 RUNTIME_FUNCTION(Runtime_ArrayPush) { | 421 RUNTIME_FUNCTION(Runtime_ArrayPush) { |
476 DCHECK_EQ(2, args.length()); | 422 DCHECK_EQ(2, args.length()); |
477 Arguments* incoming = reinterpret_cast<Arguments*>(args[0]); | 423 Arguments* incoming = reinterpret_cast<Arguments*>(args[0]); |
478 // Rewrap the arguments as builtins arguments. | 424 // Rewrap the arguments as builtins arguments. |
479 BuiltinArguments<BuiltinExtraArguments::kNone> caller_args( | 425 BuiltinArguments caller_args(incoming->length() + 3, |
480 incoming->length() + 1, incoming->arguments() + 1); | 426 incoming->arguments() + 1); |
481 return DoArrayPush(isolate, caller_args); | 427 return DoArrayPush(isolate, caller_args); |
482 } | 428 } |
483 | 429 |
484 BUILTIN(ArrayPop) { | 430 BUILTIN(ArrayPop) { |
485 HandleScope scope(isolate); | 431 HandleScope scope(isolate); |
486 Handle<Object> receiver = args.receiver(); | 432 Handle<Object> receiver = args.receiver(); |
487 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, nullptr, 0)) { | 433 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, nullptr, 0)) { |
488 return CallJsIntrinsic(isolate, isolate->array_pop(), args); | 434 return CallJsIntrinsic(isolate, isolate->array_pop(), args); |
489 } | 435 } |
490 | 436 |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 Handle<Symbol> key(isolate->factory()->is_concat_spreadable_symbol()); | 1180 Handle<Symbol> key(isolate->factory()->is_concat_spreadable_symbol()); |
1235 Handle<Object> value; | 1181 Handle<Object> value; |
1236 MaybeHandle<Object> maybeValue = | 1182 MaybeHandle<Object> maybeValue = |
1237 i::Runtime::GetObjectProperty(isolate, obj, key); | 1183 i::Runtime::GetObjectProperty(isolate, obj, key); |
1238 if (!maybeValue.ToHandle(&value)) return Nothing<bool>(); | 1184 if (!maybeValue.ToHandle(&value)) return Nothing<bool>(); |
1239 if (!value->IsUndefined(isolate)) return Just(value->BooleanValue()); | 1185 if (!value->IsUndefined(isolate)) return Just(value->BooleanValue()); |
1240 } | 1186 } |
1241 return Object::IsArray(obj); | 1187 return Object::IsArray(obj); |
1242 } | 1188 } |
1243 | 1189 |
1244 | 1190 Object* Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species, |
1245 Object* Slow_ArrayConcat(Arguments* args, Handle<Object> species, | |
1246 Isolate* isolate) { | 1191 Isolate* isolate) { |
1247 int argument_count = args->length(); | 1192 int argument_count = args->length(); |
1248 | 1193 |
1249 bool is_array_species = *species == isolate->context()->array_function(); | 1194 bool is_array_species = *species == isolate->context()->array_function(); |
1250 | 1195 |
1251 // Pass 1: estimate the length and number of elements of the result. | 1196 // Pass 1: estimate the length and number of elements of the result. |
1252 // The actual length can be larger if any of the arguments have getters | 1197 // The actual length can be larger if any of the arguments have getters |
1253 // that mutate other arguments (but will otherwise be precise). | 1198 // that mutate other arguments (but will otherwise be precise). |
1254 // The number of elements is precise if there are no inherited elements. | 1199 // The number of elements is precise if there are no inherited elements. |
1255 | 1200 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 if (map->prototype() == | 1377 if (map->prototype() == |
1433 isolate->native_context()->initial_array_prototype() && | 1378 isolate->native_context()->initial_array_prototype() && |
1434 map->NumberOfOwnDescriptors() == 1) { | 1379 map->NumberOfOwnDescriptors() == 1) { |
1435 return true; | 1380 return true; |
1436 } | 1381 } |
1437 // TODO(cbruni): slower lookup for array subclasses and support slow | 1382 // TODO(cbruni): slower lookup for array subclasses and support slow |
1438 // @@IsConcatSpreadable lookup. | 1383 // @@IsConcatSpreadable lookup. |
1439 return false; | 1384 return false; |
1440 } | 1385 } |
1441 | 1386 |
1442 MaybeHandle<JSArray> Fast_ArrayConcat(Isolate* isolate, Arguments* args) { | 1387 MaybeHandle<JSArray> Fast_ArrayConcat(Isolate* isolate, |
| 1388 BuiltinArguments* args) { |
1443 if (!isolate->IsIsConcatSpreadableLookupChainIntact()) { | 1389 if (!isolate->IsIsConcatSpreadableLookupChainIntact()) { |
1444 return MaybeHandle<JSArray>(); | 1390 return MaybeHandle<JSArray>(); |
1445 } | 1391 } |
1446 // We shouldn't overflow when adding another len. | 1392 // We shouldn't overflow when adding another len. |
1447 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); | 1393 const int kHalfOfMaxInt = 1 << (kBitsPerInt - 2); |
1448 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); | 1394 STATIC_ASSERT(FixedArray::kMaxLength < kHalfOfMaxInt); |
1449 STATIC_ASSERT(FixedDoubleArray::kMaxLength < kHalfOfMaxInt); | 1395 STATIC_ASSERT(FixedDoubleArray::kMaxLength < kHalfOfMaxInt); |
1450 USE(kHalfOfMaxInt); | 1396 USE(kHalfOfMaxInt); |
1451 | 1397 |
1452 int n_arguments = args->length(); | 1398 int n_arguments = args->length(); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 JSReceiver::GetOwnPropertyDescriptor(isolate, receiver, key, &desc); | 1843 JSReceiver::GetOwnPropertyDescriptor(isolate, receiver, key, &desc); |
1898 MAYBE_RETURN(found, isolate->heap()->exception()); | 1844 MAYBE_RETURN(found, isolate->heap()->exception()); |
1899 // 4. Return FromPropertyDescriptor(desc). | 1845 // 4. Return FromPropertyDescriptor(desc). |
1900 if (!found.FromJust()) return isolate->heap()->undefined_value(); | 1846 if (!found.FromJust()) return isolate->heap()->undefined_value(); |
1901 return *desc.ToObject(isolate); | 1847 return *desc.ToObject(isolate); |
1902 } | 1848 } |
1903 | 1849 |
1904 | 1850 |
1905 namespace { | 1851 namespace { |
1906 | 1852 |
1907 Object* GetOwnPropertyKeys(Isolate* isolate, | 1853 Object* GetOwnPropertyKeys(Isolate* isolate, BuiltinArguments args, |
1908 BuiltinArguments<BuiltinExtraArguments::kNone> args, | |
1909 PropertyFilter filter) { | 1854 PropertyFilter filter) { |
1910 HandleScope scope(isolate); | 1855 HandleScope scope(isolate); |
1911 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1856 Handle<Object> object = args.atOrUndefined(isolate, 1); |
1912 Handle<JSReceiver> receiver; | 1857 Handle<JSReceiver> receiver; |
1913 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 1858 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
1914 Object::ToObject(isolate, object)); | 1859 Object::ToObject(isolate, object)); |
1915 Handle<FixedArray> keys; | 1860 Handle<FixedArray> keys; |
1916 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1861 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1917 isolate, keys, | 1862 isolate, keys, |
1918 KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly, filter, | 1863 KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly, filter, |
(...skipping 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4282 | 4227 |
4283 // static | 4228 // static |
4284 void Builtins::Generate_DatePrototypeGetUTCSeconds(MacroAssembler* masm) { | 4229 void Builtins::Generate_DatePrototypeGetUTCSeconds(MacroAssembler* masm) { |
4285 Generate_DatePrototype_GetField(masm, JSDate::kSecondUTC); | 4230 Generate_DatePrototype_GetField(masm, JSDate::kSecondUTC); |
4286 } | 4231 } |
4287 | 4232 |
4288 | 4233 |
4289 namespace { | 4234 namespace { |
4290 | 4235 |
4291 // ES6 section 19.2.1.1.1 CreateDynamicFunction | 4236 // ES6 section 19.2.1.1.1 CreateDynamicFunction |
4292 MaybeHandle<JSFunction> CreateDynamicFunction( | 4237 MaybeHandle<JSFunction> CreateDynamicFunction(Isolate* isolate, |
4293 Isolate* isolate, | 4238 BuiltinArguments args, |
4294 BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget> args, | 4239 const char* token) { |
4295 const char* token) { | |
4296 // Compute number of arguments, ignoring the receiver. | 4240 // Compute number of arguments, ignoring the receiver. |
4297 DCHECK_LE(1, args.length()); | 4241 DCHECK_LE(1, args.length()); |
4298 int const argc = args.length() - 1; | 4242 int const argc = args.length() - 1; |
4299 | 4243 |
4300 // Build the source string. | 4244 // Build the source string. |
4301 Handle<String> source; | 4245 Handle<String> source; |
4302 { | 4246 { |
4303 IncrementalStringBuilder builder(isolate); | 4247 IncrementalStringBuilder builder(isolate); |
4304 builder.AppendCharacter('('); | 4248 builder.AppendCharacter('('); |
4305 builder.AppendCString(token); | 4249 builder.AppendCString(token); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4405 BUILTIN(FunctionConstructor) { | 4349 BUILTIN(FunctionConstructor) { |
4406 HandleScope scope(isolate); | 4350 HandleScope scope(isolate); |
4407 Handle<JSFunction> result; | 4351 Handle<JSFunction> result; |
4408 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 4352 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
4409 isolate, result, CreateDynamicFunction(isolate, args, "function")); | 4353 isolate, result, CreateDynamicFunction(isolate, args, "function")); |
4410 return *result; | 4354 return *result; |
4411 } | 4355 } |
4412 | 4356 |
4413 namespace { | 4357 namespace { |
4414 | 4358 |
4415 Object* DoFunctionBind(Isolate* isolate, | 4359 Object* DoFunctionBind(Isolate* isolate, BuiltinArguments args) { |
4416 BuiltinArguments<BuiltinExtraArguments::kNone> args) { | |
4417 HandleScope scope(isolate); | 4360 HandleScope scope(isolate); |
4418 DCHECK_LE(1, args.length()); | 4361 DCHECK_LE(1, args.length()); |
4419 if (!args.receiver()->IsCallable()) { | 4362 if (!args.receiver()->IsCallable()) { |
4420 THROW_NEW_ERROR_RETURN_FAILURE( | 4363 THROW_NEW_ERROR_RETURN_FAILURE( |
4421 isolate, NewTypeError(MessageTemplate::kFunctionBind)); | 4364 isolate, NewTypeError(MessageTemplate::kFunctionBind)); |
4422 } | 4365 } |
4423 | 4366 |
4424 // Allocate the bound function with the given {this_arg} and {args}. | 4367 // Allocate the bound function with the given {this_arg} and {args}. |
4425 Handle<JSReceiver> target = args.at<JSReceiver>(0); | 4368 Handle<JSReceiver> target = args.at<JSReceiver>(0); |
4426 Handle<Object> this_arg = isolate->factory()->undefined_value(); | 4369 Handle<Object> this_arg = isolate->factory()->undefined_value(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4501 | 4444 |
4502 // ES6 section 19.2.3.2 Function.prototype.bind ( thisArg, ...args ) | 4445 // ES6 section 19.2.3.2 Function.prototype.bind ( thisArg, ...args ) |
4503 BUILTIN(FunctionPrototypeBind) { return DoFunctionBind(isolate, args); } | 4446 BUILTIN(FunctionPrototypeBind) { return DoFunctionBind(isolate, args); } |
4504 | 4447 |
4505 // TODO(verwaest): This is a temporary helper until the FastFunctionBind stub | 4448 // TODO(verwaest): This is a temporary helper until the FastFunctionBind stub |
4506 // can tailcall to the builtin directly. | 4449 // can tailcall to the builtin directly. |
4507 RUNTIME_FUNCTION(Runtime_FunctionBind) { | 4450 RUNTIME_FUNCTION(Runtime_FunctionBind) { |
4508 DCHECK_EQ(2, args.length()); | 4451 DCHECK_EQ(2, args.length()); |
4509 Arguments* incoming = reinterpret_cast<Arguments*>(args[0]); | 4452 Arguments* incoming = reinterpret_cast<Arguments*>(args[0]); |
4510 // Rewrap the arguments as builtins arguments. | 4453 // Rewrap the arguments as builtins arguments. |
4511 BuiltinArguments<BuiltinExtraArguments::kNone> caller_args( | 4454 BuiltinArguments caller_args(incoming->length() + 3, |
4512 incoming->length() + 1, incoming->arguments() + 1); | 4455 incoming->arguments() + 1); |
4513 return DoFunctionBind(isolate, caller_args); | 4456 return DoFunctionBind(isolate, caller_args); |
4514 } | 4457 } |
4515 | 4458 |
4516 // ES6 section 19.2.3.5 Function.prototype.toString ( ) | 4459 // ES6 section 19.2.3.5 Function.prototype.toString ( ) |
4517 BUILTIN(FunctionPrototypeToString) { | 4460 BUILTIN(FunctionPrototypeToString) { |
4518 HandleScope scope(isolate); | 4461 HandleScope scope(isolate); |
4519 Handle<Object> receiver = args.receiver(); | 4462 Handle<Object> receiver = args.receiver(); |
4520 if (receiver->IsJSBoundFunction()) { | 4463 if (receiver->IsJSBoundFunction()) { |
4521 return *JSBoundFunction::ToString(Handle<JSBoundFunction>::cast(receiver)); | 4464 return *JSBoundFunction::ToString(Handle<JSBoundFunction>::cast(receiver)); |
4522 } else if (receiver->IsJSFunction()) { | 4465 } else if (receiver->IsJSFunction()) { |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5079 isolate, NewTypeError(MessageTemplate::kStrictPoisonPill)); | 5022 isolate, NewTypeError(MessageTemplate::kStrictPoisonPill)); |
5080 } | 5023 } |
5081 | 5024 |
5082 | 5025 |
5083 // ----------------------------------------------------------------------------- | 5026 // ----------------------------------------------------------------------------- |
5084 // | 5027 // |
5085 | 5028 |
5086 | 5029 |
5087 namespace { | 5030 namespace { |
5088 | 5031 |
5089 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( | 5032 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(Isolate* isolate, |
5090 Isolate* isolate, | 5033 BuiltinArguments args) { |
5091 BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget> args) { | |
5092 HandleScope scope(isolate); | 5034 HandleScope scope(isolate); |
5093 Handle<HeapObject> function = args.target<HeapObject>(); | 5035 Handle<HeapObject> function = args.target<HeapObject>(); |
5094 Handle<HeapObject> new_target = args.new_target(); | 5036 Handle<HeapObject> new_target = args.new_target(); |
5095 bool is_construct = !new_target->IsUndefined(isolate); | 5037 bool is_construct = !new_target->IsUndefined(isolate); |
5096 Handle<JSReceiver> receiver; | 5038 Handle<JSReceiver> receiver; |
5097 | 5039 |
5098 DCHECK(function->IsFunctionTemplateInfo() || | 5040 DCHECK(function->IsFunctionTemplateInfo() || |
5099 Handle<JSFunction>::cast(function)->shared()->IsApiFunction()); | 5041 Handle<JSFunction>::cast(function)->shared()->IsApiFunction()); |
5100 | 5042 |
5101 Handle<FunctionTemplateInfo> fun_data = | 5043 Handle<FunctionTemplateInfo> fun_data = |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5252 return InterpreterPushArgsAndCall(); | 5194 return InterpreterPushArgsAndCall(); |
5253 case TailCallMode::kAllow: | 5195 case TailCallMode::kAllow: |
5254 return InterpreterPushArgsAndTailCall(); | 5196 return InterpreterPushArgsAndTailCall(); |
5255 } | 5197 } |
5256 UNREACHABLE(); | 5198 UNREACHABLE(); |
5257 return Handle<Code>::null(); | 5199 return Handle<Code>::null(); |
5258 } | 5200 } |
5259 | 5201 |
5260 namespace { | 5202 namespace { |
5261 | 5203 |
5262 class RelocatableArguments | 5204 class RelocatableArguments : public BuiltinArguments, public Relocatable { |
5263 : public BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>, | |
5264 public Relocatable { | |
5265 public: | 5205 public: |
5266 RelocatableArguments(Isolate* isolate, int length, Object** arguments) | 5206 RelocatableArguments(Isolate* isolate, int length, Object** arguments) |
5267 : BuiltinArguments<BuiltinExtraArguments::kTargetAndNewTarget>(length, | 5207 : BuiltinArguments(length, arguments), Relocatable(isolate) {} |
5268 arguments), | |
5269 Relocatable(isolate) {} | |
5270 | 5208 |
5271 virtual inline void IterateInstance(ObjectVisitor* v) { | 5209 virtual inline void IterateInstance(ObjectVisitor* v) { |
5272 if (length() == 0) return; | 5210 if (length() == 0) return; |
5273 v->VisitPointers(lowest_address(), highest_address() + 1); | 5211 v->VisitPointers(lowest_address(), highest_address() + 1); |
5274 } | 5212 } |
5275 | 5213 |
5276 private: | 5214 private: |
5277 DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); | 5215 DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); |
5278 }; | 5216 }; |
5279 | 5217 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5319 delete[] argv; | 5257 delete[] argv; |
5320 } | 5258 } |
5321 return result; | 5259 return result; |
5322 } | 5260 } |
5323 | 5261 |
5324 | 5262 |
5325 // Helper function to handle calls to non-function objects created through the | 5263 // Helper function to handle calls to non-function objects created through the |
5326 // API. The object can be called as either a constructor (using new) or just as | 5264 // API. The object can be called as either a constructor (using new) or just as |
5327 // a function (without new). | 5265 // a function (without new). |
5328 MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor( | 5266 MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor( |
5329 Isolate* isolate, bool is_construct_call, | 5267 Isolate* isolate, bool is_construct_call, BuiltinArguments args) { |
5330 BuiltinArguments<BuiltinExtraArguments::kNone> args) { | |
5331 Handle<Object> receiver = args.receiver(); | 5268 Handle<Object> receiver = args.receiver(); |
5332 | 5269 |
5333 // Get the object called. | 5270 // Get the object called. |
5334 JSObject* obj = JSObject::cast(*receiver); | 5271 JSObject* obj = JSObject::cast(*receiver); |
5335 | 5272 |
5336 // Set the new target. | 5273 // Set the new target. |
5337 HeapObject* new_target; | 5274 HeapObject* new_target; |
5338 if (is_construct_call) { | 5275 if (is_construct_call) { |
5339 // TODO(adamk): This should be passed through in args instead of | 5276 // TODO(adamk): This should be passed through in args instead of |
5340 // being patched in here. We need to set a non-undefined value | 5277 // being patched in here. We need to set a non-undefined value |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5516 | 5453 |
5517 Builtins::Builtins() : initialized_(false) { | 5454 Builtins::Builtins() : initialized_(false) { |
5518 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); | 5455 memset(builtins_, 0, sizeof(builtins_[0]) * builtin_count); |
5519 memset(names_, 0, sizeof(names_[0]) * builtin_count); | 5456 memset(names_, 0, sizeof(names_[0]) * builtin_count); |
5520 } | 5457 } |
5521 | 5458 |
5522 | 5459 |
5523 Builtins::~Builtins() { | 5460 Builtins::~Builtins() { |
5524 } | 5461 } |
5525 | 5462 |
5526 | 5463 #define DEF_ENUM_C(name) FUNCTION_ADDR(Builtin_##name), |
5527 #define DEF_ENUM_C(name, ignore) FUNCTION_ADDR(Builtin_##name), | |
5528 Address const Builtins::c_functions_[cfunction_count] = { | 5464 Address const Builtins::c_functions_[cfunction_count] = { |
5529 BUILTIN_LIST_C(DEF_ENUM_C) | 5465 BUILTIN_LIST_C(DEF_ENUM_C) |
5530 }; | 5466 }; |
5531 #undef DEF_ENUM_C | 5467 #undef DEF_ENUM_C |
5532 | 5468 |
5533 | 5469 |
5534 struct BuiltinDesc { | 5470 struct BuiltinDesc { |
5535 Handle<Code> (*builder)(Isolate*, struct BuiltinDesc const*); | 5471 Handle<Code> (*builder)(Isolate*, struct BuiltinDesc const*); |
5536 byte* generator; | 5472 byte* generator; |
5537 byte* c_code; | 5473 byte* c_code; |
5538 const char* s_name; // name is only used for generating log information. | 5474 const char* s_name; // name is only used for generating log information. |
5539 int name; | 5475 int name; |
5540 Code::Flags flags; | 5476 Code::Flags flags; |
5541 BuiltinExtraArguments extra_args; | |
5542 int argc; | 5477 int argc; |
5543 }; | 5478 }; |
5544 | 5479 |
5545 #define BUILTIN_FUNCTION_TABLE_INIT { V8_ONCE_INIT, {} } | 5480 #define BUILTIN_FUNCTION_TABLE_INIT { V8_ONCE_INIT, {} } |
5546 | 5481 |
5547 class BuiltinFunctionTable { | 5482 class BuiltinFunctionTable { |
5548 public: | 5483 public: |
5549 BuiltinDesc* functions() { | 5484 BuiltinDesc* functions() { |
5550 base::CallOnce(&once_, &Builtins::InitBuiltinFunctionTable); | 5485 base::CallOnce(&once_, &Builtins::InitBuiltinFunctionTable); |
5551 return functions_; | 5486 return functions_; |
(...skipping 24 matching lines...) Expand all Loading... |
5576 const size_t buffer_size = 8 * KB; | 5511 const size_t buffer_size = 8 * KB; |
5577 #endif | 5512 #endif |
5578 union { | 5513 union { |
5579 int force_alignment; | 5514 int force_alignment; |
5580 byte buffer[buffer_size]; // NOLINT(runtime/arrays) | 5515 byte buffer[buffer_size]; // NOLINT(runtime/arrays) |
5581 } u; | 5516 } u; |
5582 | 5517 |
5583 MacroAssembler masm(isolate, u.buffer, sizeof(u.buffer), | 5518 MacroAssembler masm(isolate, u.buffer, sizeof(u.buffer), |
5584 CodeObjectRequired::kYes); | 5519 CodeObjectRequired::kYes); |
5585 // Generate the code/adaptor. | 5520 // Generate the code/adaptor. |
5586 typedef void (*Generator)(MacroAssembler*, int, BuiltinExtraArguments); | 5521 typedef void (*Generator)(MacroAssembler*, int); |
5587 Generator g = FUNCTION_CAST<Generator>(builtin_desc->generator); | 5522 Generator g = FUNCTION_CAST<Generator>(builtin_desc->generator); |
5588 // We pass all arguments to the generator, but it may not use all of | 5523 // We pass all arguments to the generator, but it may not use all of |
5589 // them. This works because the first arguments are on top of the | 5524 // them. This works because the first arguments are on top of the |
5590 // stack. | 5525 // stack. |
5591 DCHECK(!masm.has_frame()); | 5526 DCHECK(!masm.has_frame()); |
5592 g(&masm, builtin_desc->name, builtin_desc->extra_args); | 5527 g(&masm, builtin_desc->name); |
5593 // Move the code into the object heap. | 5528 // Move the code into the object heap. |
5594 CodeDesc desc; | 5529 CodeDesc desc; |
5595 masm.GetCode(&desc); | 5530 masm.GetCode(&desc); |
5596 Code::Flags flags = builtin_desc->flags; | 5531 Code::Flags flags = builtin_desc->flags; |
5597 return isolate->factory()->NewCode(desc, flags, masm.CodeObject()); | 5532 return isolate->factory()->NewCode(desc, flags, masm.CodeObject()); |
5598 } | 5533 } |
5599 | 5534 |
5600 // Builder for builtins implemented in TurboFan with JS linkage. | 5535 // Builder for builtins implemented in TurboFan with JS linkage. |
5601 Handle<Code> CodeStubAssemblerBuilderJS(Isolate* isolate, | 5536 Handle<Code> CodeStubAssemblerBuilderJS(Isolate* isolate, |
5602 BuiltinDesc const* builtin_desc) { | 5537 BuiltinDesc const* builtin_desc) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5636 // within the lexical scope of Builtins:: and within a context where | 5571 // within the lexical scope of Builtins:: and within a context where |
5637 // Code::Flags names a non-abstract type. | 5572 // Code::Flags names a non-abstract type. |
5638 void Builtins::InitBuiltinFunctionTable() { | 5573 void Builtins::InitBuiltinFunctionTable() { |
5639 BuiltinDesc* functions = builtin_function_table.functions_; | 5574 BuiltinDesc* functions = builtin_function_table.functions_; |
5640 functions[builtin_count].builder = nullptr; | 5575 functions[builtin_count].builder = nullptr; |
5641 functions[builtin_count].generator = nullptr; | 5576 functions[builtin_count].generator = nullptr; |
5642 functions[builtin_count].c_code = nullptr; | 5577 functions[builtin_count].c_code = nullptr; |
5643 functions[builtin_count].s_name = nullptr; | 5578 functions[builtin_count].s_name = nullptr; |
5644 functions[builtin_count].name = builtin_count; | 5579 functions[builtin_count].name = builtin_count; |
5645 functions[builtin_count].flags = static_cast<Code::Flags>(0); | 5580 functions[builtin_count].flags = static_cast<Code::Flags>(0); |
5646 functions[builtin_count].extra_args = BuiltinExtraArguments::kNone; | |
5647 functions[builtin_count].argc = 0; | 5581 functions[builtin_count].argc = 0; |
5648 | 5582 |
5649 #define DEF_FUNCTION_PTR_C(aname, aextra_args) \ | 5583 #define DEF_FUNCTION_PTR_C(aname) \ |
5650 functions->builder = &MacroAssemblerBuilder; \ | 5584 functions->builder = &MacroAssemblerBuilder; \ |
5651 functions->generator = FUNCTION_ADDR(Generate_Adaptor); \ | 5585 functions->generator = FUNCTION_ADDR(Generate_Adaptor); \ |
5652 functions->c_code = FUNCTION_ADDR(Builtin_##aname); \ | 5586 functions->c_code = FUNCTION_ADDR(Builtin_##aname); \ |
5653 functions->s_name = #aname; \ | 5587 functions->s_name = #aname; \ |
5654 functions->name = c_##aname; \ | 5588 functions->name = c_##aname; \ |
5655 functions->flags = Code::ComputeFlags(Code::BUILTIN); \ | 5589 functions->flags = Code::ComputeFlags(Code::BUILTIN); \ |
5656 functions->extra_args = BuiltinExtraArguments::aextra_args; \ | 5590 functions->argc = 0; \ |
5657 functions->argc = 0; \ | |
5658 ++functions; | 5591 ++functions; |
5659 | 5592 |
5660 #define DEF_FUNCTION_PTR_A(aname, kind, extra) \ | 5593 #define DEF_FUNCTION_PTR_A(aname, kind, extra) \ |
5661 functions->builder = &MacroAssemblerBuilder; \ | 5594 functions->builder = &MacroAssemblerBuilder; \ |
5662 functions->generator = FUNCTION_ADDR(Generate_##aname); \ | 5595 functions->generator = FUNCTION_ADDR(Generate_##aname); \ |
5663 functions->c_code = NULL; \ | 5596 functions->c_code = NULL; \ |
5664 functions->s_name = #aname; \ | 5597 functions->s_name = #aname; \ |
5665 functions->name = k##aname; \ | 5598 functions->name = k##aname; \ |
5666 functions->flags = Code::ComputeFlags(Code::kind, extra); \ | 5599 functions->flags = Code::ComputeFlags(Code::kind, extra); \ |
5667 functions->extra_args = BuiltinExtraArguments::kNone; \ | |
5668 functions->argc = 0; \ | 5600 functions->argc = 0; \ |
5669 ++functions; | 5601 ++functions; |
5670 | 5602 |
5671 #define DEF_FUNCTION_PTR_T(aname, aargc) \ | 5603 #define DEF_FUNCTION_PTR_T(aname, aargc) \ |
5672 functions->builder = &CodeStubAssemblerBuilderJS; \ | 5604 functions->builder = &CodeStubAssemblerBuilderJS; \ |
5673 functions->generator = FUNCTION_ADDR(Generate_##aname); \ | 5605 functions->generator = FUNCTION_ADDR(Generate_##aname); \ |
5674 functions->c_code = NULL; \ | 5606 functions->c_code = NULL; \ |
5675 functions->s_name = #aname; \ | 5607 functions->s_name = #aname; \ |
5676 functions->name = k##aname; \ | 5608 functions->name = k##aname; \ |
5677 functions->flags = Code::ComputeFlags(Code::BUILTIN); \ | 5609 functions->flags = Code::ComputeFlags(Code::BUILTIN); \ |
5678 functions->extra_args = BuiltinExtraArguments::kNone; \ | |
5679 functions->argc = aargc; \ | 5610 functions->argc = aargc; \ |
5680 ++functions; | 5611 ++functions; |
5681 | 5612 |
5682 #define DEF_FUNCTION_PTR_S(aname, kind, extra, interface_descriptor) \ | 5613 #define DEF_FUNCTION_PTR_S(aname, kind, extra, interface_descriptor) \ |
5683 functions->builder = &CodeStubAssemblerBuilderCS; \ | 5614 functions->builder = &CodeStubAssemblerBuilderCS; \ |
5684 functions->generator = FUNCTION_ADDR(Generate_##aname); \ | 5615 functions->generator = FUNCTION_ADDR(Generate_##aname); \ |
5685 functions->c_code = NULL; \ | 5616 functions->c_code = NULL; \ |
5686 functions->s_name = #aname; \ | 5617 functions->s_name = #aname; \ |
5687 functions->name = k##aname; \ | 5618 functions->name = k##aname; \ |
5688 functions->flags = Code::ComputeFlags(Code::kind, extra); \ | 5619 functions->flags = Code::ComputeFlags(Code::kind, extra); \ |
5689 functions->extra_args = BuiltinExtraArguments::kNone; \ | |
5690 functions->argc = CallDescriptors::interface_descriptor; \ | 5620 functions->argc = CallDescriptors::interface_descriptor; \ |
5691 ++functions; | 5621 ++functions; |
5692 | 5622 |
5693 #define DEF_FUNCTION_PTR_H(aname, kind) \ | 5623 #define DEF_FUNCTION_PTR_H(aname, kind) \ |
5694 functions->builder = &MacroAssemblerBuilder; \ | 5624 functions->builder = &MacroAssemblerBuilder; \ |
5695 functions->generator = FUNCTION_ADDR(Generate_##aname); \ | 5625 functions->generator = FUNCTION_ADDR(Generate_##aname); \ |
5696 functions->c_code = NULL; \ | 5626 functions->c_code = NULL; \ |
5697 functions->s_name = #aname; \ | 5627 functions->s_name = #aname; \ |
5698 functions->name = k##aname; \ | 5628 functions->name = k##aname; \ |
5699 functions->flags = Code::ComputeHandlerFlags(Code::kind); \ | 5629 functions->flags = Code::ComputeHandlerFlags(Code::kind); \ |
5700 functions->extra_args = BuiltinExtraArguments::kNone; \ | |
5701 functions->argc = 0; \ | 5630 functions->argc = 0; \ |
5702 ++functions; | 5631 ++functions; |
5703 | 5632 |
5704 BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) | 5633 BUILTIN_LIST_C(DEF_FUNCTION_PTR_C) |
5705 BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) | 5634 BUILTIN_LIST_A(DEF_FUNCTION_PTR_A) |
5706 BUILTIN_LIST_T(DEF_FUNCTION_PTR_T) | 5635 BUILTIN_LIST_T(DEF_FUNCTION_PTR_T) |
5707 BUILTIN_LIST_S(DEF_FUNCTION_PTR_S) | 5636 BUILTIN_LIST_S(DEF_FUNCTION_PTR_S) |
5708 BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) | 5637 BUILTIN_LIST_H(DEF_FUNCTION_PTR_H) |
5709 BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) | 5638 BUILTIN_LIST_DEBUG_A(DEF_FUNCTION_PTR_A) |
5710 | 5639 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6024 a->Bind(&u32); | 5953 a->Bind(&u32); |
6025 a->AtomicStore(MachineRepresentation::kWord32, backing_store, | 5954 a->AtomicStore(MachineRepresentation::kWord32, backing_store, |
6026 a->WordShl(index_word, 2), value_word32); | 5955 a->WordShl(index_word, 2), value_word32); |
6027 a->Return(value_integer); | 5956 a->Return(value_integer); |
6028 | 5957 |
6029 // This shouldn't happen, we've already validated the type. | 5958 // This shouldn't happen, we've already validated the type. |
6030 a->Bind(&other); | 5959 a->Bind(&other); |
6031 a->Return(a->Int32Constant(0)); | 5960 a->Return(a->Int32Constant(0)); |
6032 } | 5961 } |
6033 | 5962 |
6034 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \ | 5963 #define DEFINE_BUILTIN_ACCESSOR_C(name) \ |
6035 Handle<Code> Builtins::name() { \ | 5964 Handle<Code> Builtins::name() { \ |
6036 Code** code_address = \ | 5965 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ |
6037 reinterpret_cast<Code**>(builtin_address(k##name)); \ | 5966 return Handle<Code>(code_address); \ |
6038 return Handle<Code>(code_address); \ | 5967 } |
6039 } | |
6040 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, extra) \ | 5968 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, extra) \ |
6041 Handle<Code> Builtins::name() { \ | 5969 Handle<Code> Builtins::name() { \ |
6042 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ | 5970 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ |
6043 return Handle<Code>(code_address); \ | 5971 return Handle<Code>(code_address); \ |
6044 } | 5972 } |
6045 #define DEFINE_BUILTIN_ACCESSOR_T(name, argc) \ | 5973 #define DEFINE_BUILTIN_ACCESSOR_T(name, argc) \ |
6046 Handle<Code> Builtins::name() { \ | 5974 Handle<Code> Builtins::name() { \ |
6047 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ | 5975 Code** code_address = reinterpret_cast<Code**>(builtin_address(k##name)); \ |
6048 return Handle<Code>(code_address); \ | 5976 return Handle<Code>(code_address); \ |
6049 } | 5977 } |
(...skipping 15 matching lines...) Expand all Loading... |
6065 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 5993 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
6066 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 5994 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
6067 #undef DEFINE_BUILTIN_ACCESSOR_C | 5995 #undef DEFINE_BUILTIN_ACCESSOR_C |
6068 #undef DEFINE_BUILTIN_ACCESSOR_A | 5996 #undef DEFINE_BUILTIN_ACCESSOR_A |
6069 #undef DEFINE_BUILTIN_ACCESSOR_T | 5997 #undef DEFINE_BUILTIN_ACCESSOR_T |
6070 #undef DEFINE_BUILTIN_ACCESSOR_S | 5998 #undef DEFINE_BUILTIN_ACCESSOR_S |
6071 #undef DEFINE_BUILTIN_ACCESSOR_H | 5999 #undef DEFINE_BUILTIN_ACCESSOR_H |
6072 | 6000 |
6073 } // namespace internal | 6001 } // namespace internal |
6074 } // namespace v8 | 6002 } // namespace v8 |
OLD | NEW |