OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1399 SimpleInstallFunction(prototype, "toString", | 1399 SimpleInstallFunction(prototype, "toString", |
1400 Builtins::kStringPrototypeToString, 0, true); | 1400 Builtins::kStringPrototypeToString, 0, true); |
1401 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0, | 1401 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0, |
1402 false); | 1402 false); |
1403 SimpleInstallFunction(prototype, "trimLeft", | 1403 SimpleInstallFunction(prototype, "trimLeft", |
1404 Builtins::kStringPrototypeTrimLeft, 0, false); | 1404 Builtins::kStringPrototypeTrimLeft, 0, false); |
1405 SimpleInstallFunction(prototype, "trimRight", | 1405 SimpleInstallFunction(prototype, "trimRight", |
1406 Builtins::kStringPrototypeTrimRight, 0, false); | 1406 Builtins::kStringPrototypeTrimRight, 0, false); |
1407 SimpleInstallFunction(prototype, "valueOf", | 1407 SimpleInstallFunction(prototype, "valueOf", |
1408 Builtins::kStringPrototypeValueOf, 0, true); | 1408 Builtins::kStringPrototypeValueOf, 0, true); |
1409 | |
1410 Handle<JSFunction> iterator = CreateFunction( | |
1411 isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"), | |
1412 JS_OBJECT_TYPE, JSObject::kHeaderSize, MaybeHandle<JSObject>(), | |
1413 Builtins::kStringCreateIterator, true); | |
1414 iterator->shared()->set_internal_formal_parameter_count(0); | |
1415 iterator->shared()->set_length(0); | |
1416 iterator->shared()->set_language_mode(STRICT); | |
Benedikt Meurer
2016/09/15 17:34:33
Why do you need to set the language mode on a C++
caitp
2016/09/15 19:02:39
I guess the other builtins just use set_native(tru
Benedikt Meurer
2016/09/16 03:16:37
Yes, we really need a version that can deal with n
| |
1417 iterator->map()->set_is_constructor(false); | |
Benedikt Meurer
2016/09/15 17:34:33
This mutates the map inplace, which is not what yo
| |
1418 | |
1419 JSObject::AddProperty(prototype, factory->iterator_symbol(), iterator, | |
1420 static_cast<PropertyAttributes>(DONT_ENUM)); | |
1409 } | 1421 } |
1410 | 1422 |
1411 { | 1423 { |
1412 // --- S y m b o l --- | 1424 // --- S y m b o l --- |
1413 Handle<JSObject> prototype = | 1425 Handle<JSObject> prototype = |
1414 factory->NewJSObject(isolate->object_function(), TENURED); | 1426 factory->NewJSObject(isolate->object_function(), TENURED); |
1415 Handle<JSFunction> symbol_fun = | 1427 Handle<JSFunction> symbol_fun = |
1416 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, | 1428 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, |
1417 prototype, Builtins::kSymbolConstructor); | 1429 prototype, Builtins::kSymbolConstructor); |
1418 symbol_fun->shared()->SetConstructStub( | 1430 symbol_fun->shared()->SetConstructStub( |
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3375 } | 3387 } |
3376 { | 3388 { |
3377 AccessorConstantDescriptor d(factory()->iterator_symbol(), | 3389 AccessorConstantDescriptor d(factory()->iterator_symbol(), |
3378 arguments_iterator, attribs); | 3390 arguments_iterator, attribs); |
3379 Handle<Map> map(native_context()->strict_arguments_map()); | 3391 Handle<Map> map(native_context()->strict_arguments_map()); |
3380 Map::EnsureDescriptorSlack(map, 1); | 3392 Map::EnsureDescriptorSlack(map, 1); |
3381 map->AppendDescriptor(&d); | 3393 map->AppendDescriptor(&d); |
3382 } | 3394 } |
3383 } | 3395 } |
3384 | 3396 |
3397 { // StringIterator | |
3398 PrototypeIterator iter(native_context()->generator_object_prototype_map()); | |
Benedikt Meurer
2016/09/15 17:34:33
Can we make this more robust? I.e. have the iterat
caitp
2016/09/15 19:02:39
Ok.
I assume it wasn't done originally to avoid g
| |
3399 iter.Advance(); // Advance to the prototype of generator_object_prototype. | |
3400 Handle<JSObject> iterator_prototype = | |
3401 Handle<JSObject>(iter.GetCurrent<JSObject>()); | |
3402 | |
3403 Handle<JSObject> string_iterator_prototype = | |
3404 factory()->NewJSObject(isolate()->object_function(), TENURED); | |
3405 JSObject::ForceSetPrototype(string_iterator_prototype, iterator_prototype); | |
Benedikt Meurer
2016/09/15 17:34:33
Not sure about this ForceSetPrototype. We seem to
caitp
2016/09/15 19:02:39
was copy/pasted from one of the Map or Set iterato
| |
3406 | |
3407 JSObject::AddProperty( | |
3408 string_iterator_prototype, factory()->to_string_tag_symbol(), | |
3409 factory()->NewStringFromAsciiChecked("String Iterator"), | |
3410 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); | |
3411 | |
3412 InstallFunction(string_iterator_prototype, "next", JS_OBJECT_TYPE, | |
3413 JSObject::kHeaderSize, MaybeHandle<JSObject>(), | |
3414 Builtins::kStringIteratorNext); | |
3415 | |
3416 Handle<JSFunction> string_iterator_function = CreateFunction( | |
3417 isolate(), factory()->NewStringFromAsciiChecked("StringIterator"), | |
3418 JS_STRING_ITERATOR_TYPE, JSStringIterator::kSize, | |
3419 string_iterator_prototype, Builtins::kIllegal); | |
3420 native_context()->set_string_iterator_map( | |
3421 string_iterator_function->initial_map()); | |
3422 } | |
3423 | |
3385 return true; | 3424 return true; |
3386 } | 3425 } |
3387 | 3426 |
3388 | 3427 |
3389 bool Genesis::InstallExperimentalNatives() { | 3428 bool Genesis::InstallExperimentalNatives() { |
3390 static const char* harmony_explicit_tailcalls_natives[] = {nullptr}; | 3429 static const char* harmony_explicit_tailcalls_natives[] = {nullptr}; |
3391 static const char* harmony_tailcalls_natives[] = {nullptr}; | 3430 static const char* harmony_tailcalls_natives[] = {nullptr}; |
3392 static const char* harmony_sharedarraybuffer_natives[] = { | 3431 static const char* harmony_sharedarraybuffer_natives[] = { |
3393 "native harmony-atomics.js", NULL}; | 3432 "native harmony-atomics.js", NULL}; |
3394 static const char* harmony_simd_natives[] = {"native harmony-simd.js", | 3433 static const char* harmony_simd_natives[] = {"native harmony-simd.js", |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4144 } | 4183 } |
4145 | 4184 |
4146 | 4185 |
4147 // Called when the top-level V8 mutex is destroyed. | 4186 // Called when the top-level V8 mutex is destroyed. |
4148 void Bootstrapper::FreeThreadResources() { | 4187 void Bootstrapper::FreeThreadResources() { |
4149 DCHECK(!IsActive()); | 4188 DCHECK(!IsActive()); |
4150 } | 4189 } |
4151 | 4190 |
4152 } // namespace internal | 4191 } // namespace internal |
4153 } // namespace v8 | 4192 } // namespace v8 |
OLD | NEW |