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

Side by Side Diff: src/bootstrapper.cc

Issue 2313713002: Revert of [regexp] Port RegExp getters and setters (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 function->shared()->set_native(true); 358 function->shared()->set_native(true);
359 } 359 }
360 360
361 void InstallFunction(Handle<JSObject> target, Handle<JSFunction> function, 361 void InstallFunction(Handle<JSObject> target, Handle<JSFunction> function,
362 Handle<Name> name, 362 Handle<Name> name,
363 PropertyAttributes attributes = DONT_ENUM) { 363 PropertyAttributes attributes = DONT_ENUM) {
364 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked(); 364 Handle<String> name_string = Name::ToFunctionName(name).ToHandleChecked();
365 InstallFunction(target, name, function, name_string, attributes); 365 InstallFunction(target, name, function, name_string, attributes);
366 } 366 }
367 367
368 Handle<JSFunction> InstallGetter(Handle<JSObject> target,
369 Handle<Name> property_name,
370 Handle<JSFunction> getter,
371 PropertyAttributes attributes = DONT_ENUM) {
372 Handle<Object> setter = target->GetIsolate()->factory()->undefined_value();
373 JSObject::DefineAccessor(target, property_name, getter, setter, attributes)
374 .Check();
375 getter->shared()->set_native(true);
376 return getter;
377 }
378
368 Handle<JSFunction> CreateFunction(Isolate* isolate, Handle<String> name, 379 Handle<JSFunction> CreateFunction(Isolate* isolate, Handle<String> name,
369 InstanceType type, int instance_size, 380 InstanceType type, int instance_size,
370 MaybeHandle<JSObject> maybe_prototype, 381 MaybeHandle<JSObject> maybe_prototype,
371 Builtins::Name call, 382 Builtins::Name call,
372 bool strict_function_map = false) { 383 bool strict_function_map = false) {
373 Factory* factory = isolate->factory(); 384 Factory* factory = isolate->factory();
374 Handle<Code> call_code(isolate->builtins()->builtin(call)); 385 Handle<Code> call_code(isolate->builtins()->builtin(call));
375 Handle<JSObject> prototype; 386 Handle<JSObject> prototype;
376 return maybe_prototype.ToHandle(&prototype) 387 return maybe_prototype.ToHandle(&prototype)
377 ? factory->NewFunction(name, call_code, prototype, type, 388 ? factory->NewFunction(name, call_code, prototype, type,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 454
444 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base, 455 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base,
445 const char* name, Builtins::Name call, 456 const char* name, Builtins::Name call,
446 int len, bool adapt, 457 int len, bool adapt,
447 BuiltinFunctionId id) { 458 BuiltinFunctionId id) {
448 Handle<JSFunction> fun = SimpleInstallFunction(base, name, call, len, adapt); 459 Handle<JSFunction> fun = SimpleInstallFunction(base, name, call, len, adapt);
449 fun->shared()->set_builtin_function_id(id); 460 fun->shared()->set_builtin_function_id(id);
450 return fun; 461 return fun;
451 } 462 }
452 463
453 void SimpleInstallGetterSetter(Handle<JSObject> base, Handle<String> name,
454 Builtins::Name call_getter,
455 Builtins::Name call_setter,
456 PropertyAttributes attribs) {
457 Isolate* const isolate = base->GetIsolate();
458
459 Handle<String> getter_name =
460 Name::ToFunctionName(name, isolate->factory()->get_string())
461 .ToHandleChecked();
462 Handle<JSFunction> getter =
463 SimpleCreateFunction(isolate, getter_name, call_getter, 0, false);
464 getter->shared()->set_native(true);
465
466 Handle<String> setter_name =
467 Name::ToFunctionName(name, isolate->factory()->set_string())
468 .ToHandleChecked();
469 Handle<JSFunction> setter =
470 SimpleCreateFunction(isolate, setter_name, call_setter, 0, false);
471 setter->shared()->set_native(true);
472
473 JSObject::DefineAccessor(base, name, getter, setter, attribs).Check();
474 }
475
476 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
477 Handle<String> name,
478 Handle<Name> property_name,
479 Builtins::Name call, bool adapt) {
480 Isolate* const isolate = base->GetIsolate();
481
482 Handle<String> getter_name =
483 Name::ToFunctionName(name, isolate->factory()->get_string())
484 .ToHandleChecked();
485 Handle<JSFunction> getter =
486 SimpleCreateFunction(isolate, getter_name, call, 0, adapt);
487 getter->shared()->set_native(true);
488
489 Handle<Object> setter = isolate->factory()->undefined_value();
490
491 JSObject::DefineAccessor(base, property_name, getter, setter, DONT_ENUM)
492 .Check();
493
494 return getter;
495 }
496
497 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base, 464 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
498 Handle<String> name, Builtins::Name call, 465 Handle<String> name, Builtins::Name call,
499 bool adapt) { 466 bool adapt) {
500 return SimpleInstallGetter(base, name, name, call, adapt); 467 Isolate* const isolate = base->GetIsolate();
468 Handle<String> fun_name =
469 Name::ToFunctionName(name, isolate->factory()->get_string())
470 .ToHandleChecked();
471 Handle<JSFunction> fun =
472 SimpleCreateFunction(isolate, fun_name, call, 0, adapt);
473 InstallGetter(base, name, fun);
474 return fun;
501 } 475 }
502 476
503 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base, 477 Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
504 Handle<String> name, Builtins::Name call, 478 Handle<String> name, Builtins::Name call,
505 bool adapt, BuiltinFunctionId id) { 479 bool adapt, BuiltinFunctionId id) {
506 Handle<JSFunction> fun = SimpleInstallGetter(base, name, call, adapt); 480 Handle<JSFunction> fun = SimpleInstallGetter(base, name, call, adapt);
507 fun->shared()->set_builtin_function_id(id); 481 fun->shared()->set_builtin_function_id(id);
508 return fun; 482 return fun;
509 } 483 }
510 484
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 isolate->initial_object_prototype(), Builtins::kRegExpConstructor); 1580 isolate->initial_object_prototype(), Builtins::kRegExpConstructor);
1607 InstallWithIntrinsicDefaultProto(isolate, regexp_fun, 1581 InstallWithIntrinsicDefaultProto(isolate, regexp_fun,
1608 Context::REGEXP_FUNCTION_INDEX); 1582 Context::REGEXP_FUNCTION_INDEX);
1609 1583
1610 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate); 1584 Handle<SharedFunctionInfo> shared(regexp_fun->shared(), isolate);
1611 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor()); 1585 shared->SetConstructStub(*isolate->builtins()->RegExpConstructor());
1612 shared->set_instance_class_name(isolate->heap()->RegExp_string()); 1586 shared->set_instance_class_name(isolate->heap()->RegExp_string());
1613 shared->DontAdaptArguments(); 1587 shared->DontAdaptArguments();
1614 shared->set_length(2); 1588 shared->set_length(2);
1615 1589
1616 { 1590 Handle<JSObject> proto =
1617 // RegExp.prototype setup. 1591 factory->NewJSObject(isolate->object_function(), TENURED);
1618 1592 JSObject::AddProperty(proto, factory->constructor_string(), regexp_fun,
1619 Handle<JSObject> proto = 1593 DONT_ENUM);
1620 factory->NewJSObject(isolate->object_function(), TENURED); 1594 Accessors::FunctionSetPrototype(regexp_fun, proto).Assert();
1621 JSObject::AddProperty(proto, factory->constructor_string(), regexp_fun,
1622 DONT_ENUM);
1623 Accessors::FunctionSetPrototype(regexp_fun, proto).Assert();
1624
1625 SimpleInstallGetter(proto, factory->flags_string(),
1626 Builtins::kRegExpPrototypeFlagsGetter, false);
1627 SimpleInstallGetter(proto, factory->global_string(),
1628 Builtins::kRegExpPrototypeGlobalGetter, false);
1629 SimpleInstallGetter(proto, factory->ignoreCase_string(),
1630 Builtins::kRegExpPrototypeIgnoreCaseGetter, false);
1631 SimpleInstallGetter(proto, factory->multiline_string(),
1632 Builtins::kRegExpPrototypeMultilineGetter, false);
1633 SimpleInstallGetter(proto, factory->source_string(),
1634 Builtins::kRegExpPrototypeSourceGetter, false);
1635 SimpleInstallGetter(proto, factory->sticky_string(),
1636 Builtins::kRegExpPrototypeStickyGetter, false);
1637 SimpleInstallGetter(proto, factory->unicode_string(),
1638 Builtins::kRegExpPrototypeUnicodeGetter, false);
1639 }
1640
1641 {
1642 // RegExp getters and setters.
1643
1644 // TODO(jgruber): This should really be DONT_ENUM | DONT_DELETE.
1645 // However, that currently breaks layout test expectations. Note that
1646 // Firefox sets a couple of these as enumerable.
1647 const PropertyAttributes no_enum = DONT_ENUM;
1648
1649 SimpleInstallGetter(regexp_fun,
1650 factory->InternalizeUtf8String("[Symbol.species]"),
1651 factory->species_symbol(),
1652 Builtins::kRegExpPrototypeSpeciesGetter, false);
1653
1654 // Static properties set by a successful match.
1655
1656 SimpleInstallGetterSetter(regexp_fun, factory->input_string(),
1657 Builtins::kRegExpPrototypeInputGetter,
1658 Builtins::kRegExpPrototypeInputSetter,
1659 DONT_DELETE);
1660 SimpleInstallGetterSetter(regexp_fun,
1661 factory->InternalizeUtf8String("$_"),
1662 Builtins::kRegExpPrototypeInputGetter,
1663 Builtins::kRegExpPrototypeInputSetter, no_enum);
1664
1665 SimpleInstallGetterSetter(regexp_fun,
1666 factory->InternalizeUtf8String("lastMatch"),
1667 Builtins::kRegExpPrototypeLastMatchGetter,
1668 Builtins::kEmptyFunction, no_enum);
1669 SimpleInstallGetterSetter(regexp_fun,
1670 factory->InternalizeUtf8String("$&"),
1671 Builtins::kRegExpPrototypeLastMatchGetter,
1672 Builtins::kEmptyFunction, no_enum);
1673
1674 SimpleInstallGetterSetter(regexp_fun,
1675 factory->InternalizeUtf8String("lastParen"),
1676 Builtins::kRegExpPrototypeLastParenGetter,
1677 Builtins::kEmptyFunction, no_enum);
1678 SimpleInstallGetterSetter(regexp_fun,
1679 factory->InternalizeUtf8String("$+"),
1680 Builtins::kRegExpPrototypeLastParenGetter,
1681 Builtins::kEmptyFunction, no_enum);
1682
1683 SimpleInstallGetterSetter(regexp_fun,
1684 factory->InternalizeUtf8String("leftContext"),
1685 Builtins::kRegExpPrototypeLeftContextGetter,
1686 Builtins::kEmptyFunction, no_enum);
1687 SimpleInstallGetterSetter(regexp_fun,
1688 factory->InternalizeUtf8String("$`"),
1689 Builtins::kRegExpPrototypeLeftContextGetter,
1690 Builtins::kEmptyFunction, no_enum);
1691
1692 SimpleInstallGetterSetter(regexp_fun,
1693 factory->InternalizeUtf8String("rightContext"),
1694 Builtins::kRegExpPrototypeRightContextGetter,
1695 Builtins::kEmptyFunction, no_enum);
1696 SimpleInstallGetterSetter(regexp_fun,
1697 factory->InternalizeUtf8String("$'"),
1698 Builtins::kRegExpPrototypeRightContextGetter,
1699 Builtins::kEmptyFunction, no_enum);
1700
1701 #define INSTALL_CAPTURE_GETTER(i) \
1702 SimpleInstallGetterSetter(regexp_fun, \
1703 factory->InternalizeUtf8String("$" #i), \
1704 Builtins::kRegExpPrototypeCapture##i##Getter, \
1705 Builtins::kEmptyFunction, DONT_DELETE)
1706 INSTALL_CAPTURE_GETTER(1);
1707 INSTALL_CAPTURE_GETTER(2);
1708 INSTALL_CAPTURE_GETTER(3);
1709 INSTALL_CAPTURE_GETTER(4);
1710 INSTALL_CAPTURE_GETTER(5);
1711 INSTALL_CAPTURE_GETTER(6);
1712 INSTALL_CAPTURE_GETTER(7);
1713 INSTALL_CAPTURE_GETTER(8);
1714 INSTALL_CAPTURE_GETTER(9);
1715 #undef INSTALL_CAPTURE_GETTER
1716 }
1717
1718 // TODO(jgruber): shared->set_force_inline on getters.
1719 1595
1720 DCHECK(regexp_fun->has_initial_map()); 1596 DCHECK(regexp_fun->has_initial_map());
1721 Handle<Map> initial_map(regexp_fun->initial_map()); 1597 Handle<Map> initial_map(regexp_fun->initial_map());
1722 1598
1723 DCHECK_EQ(0, initial_map->GetInObjectProperties()); 1599 DCHECK_EQ(0, initial_map->GetInObjectProperties());
1724 1600
1725 Map::EnsureDescriptorSlack(initial_map, 1); 1601 Map::EnsureDescriptorSlack(initial_map, 1);
1726 1602
1727 // ECMA-262, section 15.10.7.5. 1603 // ECMA-262, section 15.10.7.5.
1728 PropertyAttributes writable = 1604 PropertyAttributes writable =
(...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after
4226 } 4102 }
4227 4103
4228 4104
4229 // Called when the top-level V8 mutex is destroyed. 4105 // Called when the top-level V8 mutex is destroyed.
4230 void Bootstrapper::FreeThreadResources() { 4106 void Bootstrapper::FreeThreadResources() {
4231 DCHECK(!IsActive()); 4107 DCHECK(!IsActive());
4232 } 4108 }
4233 4109
4234 } // namespace internal 4110 } // namespace internal
4235 } // namespace v8 4111 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698