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

Side by Side Diff: src/bootstrapper.cc

Issue 2348493003: [builtins] move String.prototype[@@iterator] to C++ builtin (Closed)
Patch Set: V8 (rebase + fix bytecode expectations) Created 4 years, 2 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
« no previous file with comments | « src/ast/ast-types.cc ('k') | src/builtins/builtins.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 SimpleInstallFunction(prototype, "toString", 1411 SimpleInstallFunction(prototype, "toString",
1402 Builtins::kStringPrototypeToString, 0, true); 1412 Builtins::kStringPrototypeToString, 0, true);
1403 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0, 1413 SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0,
1404 false); 1414 false);
1405 SimpleInstallFunction(prototype, "trimLeft", 1415 SimpleInstallFunction(prototype, "trimLeft",
1406 Builtins::kStringPrototypeTrimLeft, 0, false); 1416 Builtins::kStringPrototypeTrimLeft, 0, false);
1407 SimpleInstallFunction(prototype, "trimRight", 1417 SimpleInstallFunction(prototype, "trimRight",
1408 Builtins::kStringPrototypeTrimRight, 0, false); 1418 Builtins::kStringPrototypeTrimRight, 0, false);
1409 SimpleInstallFunction(prototype, "valueOf", 1419 SimpleInstallFunction(prototype, "valueOf",
1410 Builtins::kStringPrototypeValueOf, 0, true); 1420 Builtins::kStringPrototypeValueOf, 0, true);
1421
1422 Handle<JSFunction> iterator = SimpleCreateFunction(
1423 isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"),
1424 Builtins::kStringPrototypeIterator, 0, true);
1425 iterator->shared()->set_native(true);
1426 JSObject::AddProperty(prototype, factory->iterator_symbol(), iterator,
1427 static_cast<PropertyAttributes>(DONT_ENUM));
1428 }
1429
1430 { // --- S t r i n g I t e r a t o r ---
1431 Handle<JSObject> iterator_prototype(
1432 native_context()->initial_iterator_prototype());
1433
1434 Handle<JSObject> string_iterator_prototype =
1435 factory->NewJSObject(isolate->object_function(), TENURED);
1436 JSObject::ForceSetPrototype(string_iterator_prototype, iterator_prototype);
1437
1438 JSObject::AddProperty(
1439 string_iterator_prototype, factory->to_string_tag_symbol(),
1440 factory->NewStringFromAsciiChecked("String Iterator"),
1441 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
1442
1443 InstallFunction(string_iterator_prototype, "next", JS_OBJECT_TYPE,
1444 JSObject::kHeaderSize, MaybeHandle<JSObject>(),
1445 Builtins::kStringIteratorPrototypeNext);
1446
1447 Handle<JSFunction> string_iterator_function = CreateFunction(
1448 isolate, factory->NewStringFromAsciiChecked("StringIterator"),
1449 JS_STRING_ITERATOR_TYPE, JSStringIterator::kSize,
1450 string_iterator_prototype, Builtins::kIllegal);
1451 native_context()->set_string_iterator_map(
1452 string_iterator_function->initial_map());
1411 } 1453 }
1412 1454
1413 { 1455 {
1414 // --- S y m b o l --- 1456 // --- S y m b o l ---
1415 Handle<JSObject> prototype = 1457 Handle<JSObject> prototype =
1416 factory->NewJSObject(isolate->object_function(), TENURED); 1458 factory->NewJSObject(isolate->object_function(), TENURED);
1417 Handle<JSFunction> symbol_fun = 1459 Handle<JSFunction> symbol_fun =
1418 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, 1460 InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
1419 prototype, Builtins::kSymbolConstructor); 1461 prototype, Builtins::kSymbolConstructor);
1420 symbol_fun->shared()->SetConstructStub( 1462 symbol_fun->shared()->SetConstructStub(
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 2503
2462 { 2504 {
2463 Handle<JSFunction> to_string = InstallFunction( 2505 Handle<JSFunction> to_string = InstallFunction(
2464 container, "object_to_string", JS_OBJECT_TYPE, JSObject::kHeaderSize, 2506 container, "object_to_string", JS_OBJECT_TYPE, JSObject::kHeaderSize,
2465 MaybeHandle<JSObject>(), Builtins::kObjectProtoToString); 2507 MaybeHandle<JSObject>(), Builtins::kObjectProtoToString);
2466 to_string->shared()->set_internal_formal_parameter_count(0); 2508 to_string->shared()->set_internal_formal_parameter_count(0);
2467 to_string->shared()->set_length(0); 2509 to_string->shared()->set_length(0);
2468 native_context->set_object_to_string(*to_string); 2510 native_context->set_object_to_string(*to_string);
2469 } 2511 }
2470 2512
2471 Handle<JSObject> iterator_prototype; 2513 Handle<JSObject> iterator_prototype(
2514 native_context->initial_iterator_prototype());
2472 2515
2473 { 2516 JSObject::AddProperty(container,
2474 PrototypeIterator iter(native_context->generator_object_prototype_map()); 2517 factory->InternalizeUtf8String("IteratorPrototype"),
2475 iter.Advance(); // Advance to the prototype of generator_object_prototype. 2518 iterator_prototype, NONE);
2476 iterator_prototype = Handle<JSObject>(iter.GetCurrent<JSObject>());
2477
2478 JSObject::AddProperty(container,
2479 factory->InternalizeUtf8String("IteratorPrototype"),
2480 iterator_prototype, NONE);
2481 }
2482 2519
2483 { 2520 {
2484 PrototypeIterator iter(native_context->sloppy_generator_function_map()); 2521 PrototypeIterator iter(native_context->sloppy_generator_function_map());
2485 Handle<JSObject> generator_function_prototype(iter.GetCurrent<JSObject>()); 2522 Handle<JSObject> generator_function_prototype(iter.GetCurrent<JSObject>());
2486 2523
2487 JSObject::AddProperty( 2524 JSObject::AddProperty(
2488 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"), 2525 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"),
2489 generator_function_prototype, NONE); 2526 generator_function_prototype, NONE);
2490 2527
2491 static const bool kUseStrictFunctionMap = true; 2528 static const bool kUseStrictFunctionMap = true;
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
4148 } 4185 }
4149 4186
4150 4187
4151 // Called when the top-level V8 mutex is destroyed. 4188 // Called when the top-level V8 mutex is destroyed.
4152 void Bootstrapper::FreeThreadResources() { 4189 void Bootstrapper::FreeThreadResources() {
4153 DCHECK(!IsActive()); 4190 DCHECK(!IsActive());
4154 } 4191 }
4155 4192
4156 } // namespace internal 4193 } // namespace internal
4157 } // namespace v8 4194 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-types.cc ('k') | src/builtins/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698