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

Side by Side Diff: src/bootstrapper.cc

Issue 2006733004: Make %ThrowTypeError% function(s) strict (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | test/test262/test262.status » ('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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower(); 158 Handle<JSFunction> GetRestrictedFunctionPropertiesThrower();
159 Handle<JSFunction> GetStrictArgumentsPoisonFunction(); 159 Handle<JSFunction> GetStrictArgumentsPoisonFunction();
160 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name); 160 Handle<JSFunction> GetThrowTypeErrorIntrinsic(Builtins::Name builtin_name);
161 161
162 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); 162 void CreateStrictModeFunctionMaps(Handle<JSFunction> empty);
163 void CreateIteratorMaps(Handle<JSFunction> empty); 163 void CreateIteratorMaps(Handle<JSFunction> empty);
164 void CreateAsyncFunctionMaps(Handle<JSFunction> empty); 164 void CreateAsyncFunctionMaps(Handle<JSFunction> empty);
165 void CreateJSProxyMaps(); 165 void CreateJSProxyMaps();
166 166
167 // Make the "arguments" and "caller" properties throw a TypeError on access. 167 // Make the "arguments" and "caller" properties throw a TypeError on access.
168 void AddRestrictedFunctionProperties(Handle<Map> map); 168 void AddRestrictedFunctionProperties(Handle<JSFunction> empty);
169 169
170 // Creates the global objects using the global proxy and the template passed 170 // Creates the global objects using the global proxy and the template passed
171 // in through the API. We call this regardless of whether we are building a 171 // in through the API. We call this regardless of whether we are building a
172 // context from scratch or using a deserialized one from the partial snapshot 172 // context from scratch or using a deserialized one from the partial snapshot
173 // but in the latter case we don't use the objects it produces directly, as 173 // but in the latter case we don't use the objects it produces directly, as
174 // we have to used the deserialized ones that are linked together with the 174 // we have to used the deserialized ones that are linked together with the
175 // rest of the context snapshot. 175 // rest of the context snapshot.
176 Handle<JSGlobalObject> CreateNewGlobals( 176 Handle<JSGlobalObject> CreateNewGlobals(
177 v8::Local<v8::ObjectTemplate> global_proxy_template, 177 v8::Local<v8::ObjectTemplate> global_proxy_template,
178 Handle<JSGlobalProxy> global_proxy); 178 Handle<JSGlobalProxy> global_proxy);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 602
603 // Set prototypes for the function maps. 603 // Set prototypes for the function maps.
604 Handle<Map> sloppy_function_map(native_context()->sloppy_function_map(), 604 Handle<Map> sloppy_function_map(native_context()->sloppy_function_map(),
605 isolate); 605 isolate);
606 Handle<Map> sloppy_function_without_prototype_map( 606 Handle<Map> sloppy_function_without_prototype_map(
607 native_context()->sloppy_function_without_prototype_map(), isolate); 607 native_context()->sloppy_function_without_prototype_map(), isolate);
608 Map::SetPrototype(sloppy_function_map, empty_function); 608 Map::SetPrototype(sloppy_function_map, empty_function);
609 Map::SetPrototype(sloppy_function_without_prototype_map, empty_function); 609 Map::SetPrototype(sloppy_function_without_prototype_map, empty_function);
610 Map::SetPrototype(sloppy_function_map_writable_prototype_, empty_function); 610 Map::SetPrototype(sloppy_function_map_writable_prototype_, empty_function);
611 611
612 // ES6 draft 03-17-2015, section 8.2.2 step 12
613 AddRestrictedFunctionProperties(empty_function_map);
614
615 return empty_function; 612 return empty_function;
616 } 613 }
617 614
618 615
619 void Genesis::SetStrictFunctionInstanceDescriptor(Handle<Map> map, 616 void Genesis::SetStrictFunctionInstanceDescriptor(Handle<Map> map,
620 FunctionMode function_mode) { 617 FunctionMode function_mode) {
621 int size = IsFunctionModeWithPrototype(function_mode) ? 3 : 2; 618 int size = IsFunctionModeWithPrototype(function_mode) ? 3 : 2;
622 Map::EnsureDescriptorSlack(map, size); 619 Map::EnsureDescriptorSlack(map, size);
623 620
624 PropertyAttributes rw_attribs = 621 PropertyAttributes rw_attribs =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 } 656 }
660 657
661 658
662 // Creates the %ThrowTypeError% function. 659 // Creates the %ThrowTypeError% function.
663 Handle<JSFunction> Genesis::GetThrowTypeErrorIntrinsic( 660 Handle<JSFunction> Genesis::GetThrowTypeErrorIntrinsic(
664 Builtins::Name builtin_name) { 661 Builtins::Name builtin_name) {
665 Handle<String> name = 662 Handle<String> name =
666 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("ThrowTypeError")); 663 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("ThrowTypeError"));
667 Handle<Code> code(isolate()->builtins()->builtin(builtin_name)); 664 Handle<Code> code(isolate()->builtins()->builtin(builtin_name));
668 Handle<JSFunction> function = 665 Handle<JSFunction> function =
669 factory()->NewFunctionWithoutPrototype(name, code); 666 factory()->NewFunctionWithoutPrototype(name, code, true);
670 function->shared()->DontAdaptArguments(); 667 function->shared()->DontAdaptArguments();
671 668
672 // %ThrowTypeError% must not have a name property. 669 // %ThrowTypeError% must not have a name property.
673 if (JSReceiver::DeleteProperty(function, factory()->name_string()) 670 if (JSReceiver::DeleteProperty(function, factory()->name_string())
674 .IsNothing()) { 671 .IsNothing()) {
675 DCHECK(false); 672 DCHECK(false);
676 } 673 }
677 674
678 // length needs to be non configurable. 675 // length needs to be non configurable.
679 Handle<Object> value(Smi::FromInt(function->shared()->length()), isolate()); 676 Handle<Object> value(Smi::FromInt(function->shared()->length()), isolate());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 // only for processing of builtins. 729 // only for processing of builtins.
733 // Later the map is replaced with writable prototype map, allocated below. 730 // Later the map is replaced with writable prototype map, allocated below.
734 Handle<Map> strict_function_map = 731 Handle<Map> strict_function_map =
735 CreateStrictFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE, empty); 732 CreateStrictFunctionMap(FUNCTION_WITH_READONLY_PROTOTYPE, empty);
736 native_context()->set_strict_function_map(*strict_function_map); 733 native_context()->set_strict_function_map(*strict_function_map);
737 734
738 // The final map for the strict mode functions. Writeable prototype. 735 // The final map for the strict mode functions. Writeable prototype.
739 // This map is installed in MakeFunctionInstancePrototypeWritable. 736 // This map is installed in MakeFunctionInstancePrototypeWritable.
740 strict_function_map_writable_prototype_ = 737 strict_function_map_writable_prototype_ =
741 CreateStrictFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE, empty); 738 CreateStrictFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE, empty);
739
740 // Now that the strict mode function map is available, set up the
741 // restricted "arguments" and "caller" getters.
742 AddRestrictedFunctionProperties(empty);
742 } 743 }
743 744
744 void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) { 745 void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) {
745 // Create iterator-related meta-objects. 746 // Create iterator-related meta-objects.
746 Handle<JSObject> iterator_prototype = 747 Handle<JSObject> iterator_prototype =
747 factory()->NewJSObject(isolate()->object_function(), TENURED); 748 factory()->NewJSObject(isolate()->object_function(), TENURED);
748 Handle<JSObject> generator_object_prototype = 749 Handle<JSObject> generator_object_prototype =
749 factory()->NewJSObject(isolate()->object_function(), TENURED); 750 factory()->NewJSObject(isolate()->object_function(), TENURED);
750 native_context()->set_initial_generator_prototype( 751 native_context()->set_initial_generator_prototype(
751 *generator_object_prototype); 752 *generator_object_prototype);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 static void ReplaceAccessors(Handle<Map> map, 862 static void ReplaceAccessors(Handle<Map> map,
862 Handle<String> name, 863 Handle<String> name,
863 PropertyAttributes attributes, 864 PropertyAttributes attributes,
864 Handle<AccessorPair> accessor_pair) { 865 Handle<AccessorPair> accessor_pair) {
865 DescriptorArray* descriptors = map->instance_descriptors(); 866 DescriptorArray* descriptors = map->instance_descriptors();
866 int idx = descriptors->SearchWithCache(map->GetIsolate(), *name, *map); 867 int idx = descriptors->SearchWithCache(map->GetIsolate(), *name, *map);
867 AccessorConstantDescriptor descriptor(name, accessor_pair, attributes); 868 AccessorConstantDescriptor descriptor(name, accessor_pair, attributes);
868 descriptors->Replace(idx, &descriptor); 869 descriptors->Replace(idx, &descriptor);
869 } 870 }
870 871
871 872 void Genesis::AddRestrictedFunctionProperties(Handle<JSFunction> empty) {
872 void Genesis::AddRestrictedFunctionProperties(Handle<Map> map) {
873 PropertyAttributes rw_attribs = static_cast<PropertyAttributes>(DONT_ENUM); 873 PropertyAttributes rw_attribs = static_cast<PropertyAttributes>(DONT_ENUM);
874 Handle<JSFunction> thrower = GetRestrictedFunctionPropertiesThrower(); 874 Handle<JSFunction> thrower = GetRestrictedFunctionPropertiesThrower();
875 Handle<AccessorPair> accessors = factory()->NewAccessorPair(); 875 Handle<AccessorPair> accessors = factory()->NewAccessorPair();
876 accessors->set_getter(*thrower); 876 accessors->set_getter(*thrower);
877 accessors->set_setter(*thrower); 877 accessors->set_setter(*thrower);
878 878
879 Handle<Map> map(empty->map());
879 ReplaceAccessors(map, factory()->arguments_string(), rw_attribs, accessors); 880 ReplaceAccessors(map, factory()->arguments_string(), rw_attribs, accessors);
880 ReplaceAccessors(map, factory()->caller_string(), rw_attribs, accessors); 881 ReplaceAccessors(map, factory()->caller_string(), rw_attribs, accessors);
881 } 882 }
882 883
883 884
884 static void AddToWeakNativeContextList(Context* context) { 885 static void AddToWeakNativeContextList(Context* context) {
885 DCHECK(context->IsNativeContext()); 886 DCHECK(context->IsNativeContext());
886 Heap* heap = context->GetIsolate()->heap(); 887 Heap* heap = context->GetIsolate()->heap();
887 #ifdef DEBUG 888 #ifdef DEBUG
888 { // NOLINT 889 { // NOLINT
(...skipping 2887 matching lines...) Expand 10 before | Expand all | Expand 10 after
3776 } 3777 }
3777 3778
3778 3779
3779 // Called when the top-level V8 mutex is destroyed. 3780 // Called when the top-level V8 mutex is destroyed.
3780 void Bootstrapper::FreeThreadResources() { 3781 void Bootstrapper::FreeThreadResources() {
3781 DCHECK(!IsActive()); 3782 DCHECK(!IsActive());
3782 } 3783 }
3783 3784
3784 } // namespace internal 3785 } // namespace internal
3785 } // namespace v8 3786 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698