Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: src/bootstrapper.cc

Issue 2348493003: [builtins] move String.prototype[@@iterator] to C++ builtin (Closed)
Patch Set: V5 (try to make gcmole happy) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 653
654 // Now that the strict mode function map is available, set up the 654 // Now that the strict mode function map is available, set up the
655 // restricted "arguments" and "caller" getters. 655 // restricted "arguments" and "caller" getters.
656 AddRestrictedFunctionProperties(empty); 656 AddRestrictedFunctionProperties(empty);
657 } 657 }
658 658
659 void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) { 659 void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) {
660 // Create iterator-related meta-objects. 660 // Create iterator-related meta-objects.
661 Handle<JSObject> iterator_prototype = 661 Handle<JSObject> iterator_prototype =
662 factory()->NewJSObject(isolate()->object_function(), TENURED); 662 factory()->NewJSObject(isolate()->object_function(), TENURED);
663
664 Handle<JSFunction> iterator_prototype_iterator = SimpleCreateFunction(
665 isolate(), factory()->NewStringFromAsciiChecked("[Symbol.iterator]"),
666 Builtins::kIteratorPrototypeIterator, 0, false);
667 iterator_prototype_iterator->shared()->set_native(true);
668
669 JSObject::AddProperty(iterator_prototype, factory()->iterator_symbol(),
670 iterator_prototype_iterator, DONT_ENUM);
671 native_context()->set_initial_iterator_prototype(*iterator_prototype);
672
663 Handle<JSObject> generator_object_prototype = 673 Handle<JSObject> generator_object_prototype =
664 factory()->NewJSObject(isolate()->object_function(), TENURED); 674 factory()->NewJSObject(isolate()->object_function(), TENURED);
665 native_context()->set_initial_generator_prototype( 675 native_context()->set_initial_generator_prototype(
666 *generator_object_prototype); 676 *generator_object_prototype);
667 JSObject::ForceSetPrototype(generator_object_prototype, iterator_prototype); 677 JSObject::ForceSetPrototype(generator_object_prototype, iterator_prototype);
668 Handle<JSObject> generator_function_prototype = 678 Handle<JSObject> generator_function_prototype =
669 factory()->NewJSObject(isolate()->object_function(), TENURED); 679 factory()->NewJSObject(isolate()->object_function(), TENURED);
670 JSObject::ForceSetPrototype(generator_function_prototype, empty); 680 JSObject::ForceSetPrototype(generator_function_prototype, empty);
671 681
672 JSObject::AddProperty( 682 JSObject::AddProperty(
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 SimpleInstallFunction(prototype, "toString", 1409 SimpleInstallFunction(prototype, "toString",
1400 Builtins::kStringPrototypeToString, 0, true); 1410 Builtins::kStringPrototypeToString, 0, true);
1401 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0, 1411 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0,
1402 false); 1412 false);
1403 SimpleInstallFunction(prototype, "trimLeft", 1413 SimpleInstallFunction(prototype, "trimLeft",
1404 Builtins::kStringPrototypeTrimLeft, 0, false); 1414 Builtins::kStringPrototypeTrimLeft, 0, false);
1405 SimpleInstallFunction(prototype, "trimRight", 1415 SimpleInstallFunction(prototype, "trimRight",
1406 Builtins::kStringPrototypeTrimRight, 0, false); 1416 Builtins::kStringPrototypeTrimRight, 0, false);
1407 SimpleInstallFunction(prototype, "valueOf", 1417 SimpleInstallFunction(prototype, "valueOf",
1408 Builtins::kStringPrototypeValueOf, 0, true); 1418 Builtins::kStringPrototypeValueOf, 0, true);
1419
1420 Handle<JSFunction> iterator = SimpleCreateFunction(
1421 isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"),
1422 Builtins::kStringPrototypeIterator, 0, true);
1423 iterator->shared()->set_native(true);
1424 JSObject::AddProperty(prototype, factory->iterator_symbol(), iterator,
1425 static_cast<PropertyAttributes>(DONT_ENUM));
1426 }
1427
1428 { // --- S t r i n g I t e r a t o r ---
1429 Handle<JSObject> iterator_prototype(
1430 native_context()->initial_iterator_prototype());
1431
1432 Handle<JSObject> string_iterator_prototype =
1433 factory->NewJSObject(isolate->object_function(), TENURED);
1434 JSObject::ForceSetPrototype(string_iterator_prototype, iterator_prototype);
1435
1436 JSObject::AddProperty(
1437 string_iterator_prototype, factory->to_string_tag_symbol(),
1438 factory->NewStringFromAsciiChecked("String Iterator"),
1439 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1440
1441 InstallFunction(string_iterator_prototype, "next", JS_OBJECT_TYPE,
1442 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
1443 Builtins::kStringIteratorPrototypeNext);
1444
1445 Handle<JSFunction> string_iterator_function = CreateFunction(
1446 isolate, factory->NewStringFromAsciiChecked("StringIterator"),
1447 JS_STRING_ITERATOR_TYPE, JSStringIterator::kSize,
1448 string_iterator_prototype, Builtins::kIllegal);
1449 native_context()->set_string_iterator_map(
1450 string_iterator_function->initial_map());
1409 } 1451 }
1410 1452
1411 { 1453 {
1412 // --- S y m b o l --- 1454 // --- S y m b o l ---
1413 Handle<JSObject> prototype = 1455 Handle<JSObject> prototype =
1414 factory->NewJSObject(isolate->object_function(), TENURED); 1456 factory->NewJSObject(isolate->object_function(), TENURED);
1415 Handle<JSFunction> symbol_fun = 1457 Handle<JSFunction> symbol_fun =
1416 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 1458 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
1417 prototype, Builtins::kSymbolConstructor); 1459 prototype, Builtins::kSymbolConstructor);
1418 symbol_fun->shared()->SetConstructStub( 1460 symbol_fun->shared()->SetConstructStub(
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 2501
2460 { 2502 {
2461 Handle<JSFunction> to_string = InstallFunction( 2503 Handle<JSFunction> to_string = InstallFunction(
2462 container, "object_to_string", JS_OBJECT_TYPE, JSObject::kHeaderSize, 2504 container, "object_to_string", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2463 MaybeHandle<JSObject>(), Builtins::kObjectProtoToString); 2505 MaybeHandle<JSObject>(), Builtins::kObjectProtoToString);
2464 to_string->shared()->set_internal_formal_parameter_count(0); 2506 to_string->shared()->set_internal_formal_parameter_count(0);
2465 to_string->shared()->set_length(0); 2507 to_string->shared()->set_length(0);
2466 native_context->set_object_to_string(*to_string); 2508 native_context->set_object_to_string(*to_string);
2467 } 2509 }
2468 2510
2469 Handle<JSObject> iterator_prototype; 2511 Handle<JSObject> iterator_prototype(
2512 native_context->initial_iterator_prototype());
2470 2513
2471 { 2514 JSObject::AddProperty(container,
2472 PrototypeIterator iter(native_context->generator_object_prototype_map()); 2515 factory->InternalizeUtf8String("IteratorPrototype"),
2473 iter.Advance(); // Advance to the prototype of generator_object_prototype. 2516 iterator_prototype, NONE);
2474 iterator_prototype = Handle<JSObject>(iter.GetCurrent<JSObject>());
2475
2476 JSObject::AddProperty(container,
2477 factory->InternalizeUtf8String("IteratorPrototype"),
2478 iterator_prototype, NONE);
2479 }
2480 2517
2481 { 2518 {
2482 PrototypeIterator iter(native_context->sloppy_generator_function_map()); 2519 PrototypeIterator iter(native_context->sloppy_generator_function_map());
2483 Handle<JSObject> generator_function_prototype(iter.GetCurrent<JSObject>()); 2520 Handle<JSObject> generator_function_prototype(iter.GetCurrent<JSObject>());
2484 2521
2485 JSObject::AddProperty( 2522 JSObject::AddProperty(
2486 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"), 2523 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"),
2487 generator_function_prototype, NONE); 2524 generator_function_prototype, NONE);
2488 2525
2489 static const bool kUseStrictFunctionMap = true; 2526 static const bool kUseStrictFunctionMap = true;
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
4144 } 4181 }
4145 4182
4146 4183
4147 // Called when the top-level V8 mutex is destroyed. 4184 // Called when the top-level V8 mutex is destroyed.
4148 void Bootstrapper::FreeThreadResources() { 4185 void Bootstrapper::FreeThreadResources() {
4149 DCHECK(!IsActive()); 4186 DCHECK(!IsActive());
4150 } 4187 }
4151 4188
4152 } // namespace internal 4189 } // namespace internal
4153 } // namespace v8 4190 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-types.cc ('k') | src/builtins/builtins.h » ('j') | src/builtins/builtins-string.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698