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

Side by Side Diff: src/bootstrapper.cc

Issue 1510753005: Fix Function subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments Created 5 years 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/heap/heap.h » ('j') | src/objects.cc » ('J')
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 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 factory->NewScriptContextTable(); 1051 factory->NewScriptContextTable();
1052 native_context()->set_script_context_table(*script_context_table); 1052 native_context()->set_script_context_table(*script_context_table);
1053 InstallGlobalThisBinding(); 1053 InstallGlobalThisBinding();
1054 1054
1055 Handle<String> object_name = factory->Object_string(); 1055 Handle<String> object_name = factory->Object_string();
1056 JSObject::AddProperty( 1056 JSObject::AddProperty(
1057 global_object, object_name, isolate->object_function(), DONT_ENUM); 1057 global_object, object_name, isolate->object_function(), DONT_ENUM);
1058 1058
1059 Handle<JSObject> global(native_context()->global_object()); 1059 Handle<JSObject> global(native_context()->global_object());
1060 1060
1061 // Install global Function object 1061 { // --- F u n c t i o n ---
1062 Handle<JSFunction> function_function = 1062 Handle<JSFunction> function_function =
1063 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize, 1063 InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
1064 empty_function, Builtins::kIllegal); 1064 empty_function, Builtins::kIllegal);
1065 function_function->initial_map()->set_is_callable(); 1065 function_function->set_prototype_or_initial_map(
1066 function_function->initial_map()->set_is_constructor(true); 1066 *sloppy_function_map_writable_prototype_);
1067 function_function->shared()->set_construct_stub( 1067 function_function->shared()->set_construct_stub(
1068 *isolate->builtins()->JSBuiltinsConstructStub()); 1068 *isolate->builtins()->JSBuiltinsConstructStub());
1069
1070 sloppy_function_map_writable_prototype_->set_constructor_or_backpointer(
Toon Verwaest 2015/12/09 21:40:03 SetConstructor?
Igor Sheludko 2015/12/10 10:50:41 Done.
1071 *function_function);
1072 strict_function_map_writable_prototype_->set_constructor_or_backpointer(
1073 *function_function);
1074 native_context()->strong_function_map()->set_constructor_or_backpointer(
1075 *function_function);
1076 }
1069 1077
1070 { // --- A r r a y --- 1078 { // --- A r r a y ---
1071 Handle<JSFunction> array_function = 1079 Handle<JSFunction> array_function =
1072 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize, 1080 InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
1073 isolate->initial_object_prototype(), 1081 isolate->initial_object_prototype(),
1074 Builtins::kArrayCode); 1082 Builtins::kArrayCode);
1075 array_function->shared()->DontAdaptArguments(); 1083 array_function->shared()->DontAdaptArguments();
1076 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode)); 1084 array_function->shared()->set_function_data(Smi::FromInt(kArrayCode));
1077 1085
1078 // This seems a bit hackish, but we need to make sure Array.length 1086 // This seems a bit hackish, but we need to make sure Array.length
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 1773
1766 JSObject::AddProperty( 1774 JSObject::AddProperty(
1767 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"), 1775 container, factory->InternalizeUtf8String("GeneratorFunctionPrototype"),
1768 generator_function_prototype, NONE); 1776 generator_function_prototype, NONE);
1769 1777
1770 static const bool kUseStrictFunctionMap = true; 1778 static const bool kUseStrictFunctionMap = true;
1771 Handle<JSFunction> generator_function_function = 1779 Handle<JSFunction> generator_function_function =
1772 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE, 1780 InstallFunction(container, "GeneratorFunction", JS_FUNCTION_TYPE,
1773 JSFunction::kSize, generator_function_prototype, 1781 JSFunction::kSize, generator_function_prototype,
1774 Builtins::kIllegal, kUseStrictFunctionMap); 1782 Builtins::kIllegal, kUseStrictFunctionMap);
1775 generator_function_function->initial_map()->set_is_callable(); 1783 generator_function_function->set_prototype_or_initial_map(
1776 generator_function_function->initial_map()->set_is_constructor(true); 1784 native_context->sloppy_generator_function_map());
1777 generator_function_function->shared()->set_construct_stub( 1785 generator_function_function->shared()->set_construct_stub(
1778 *isolate->builtins()->JSBuiltinsConstructStub()); 1786 *isolate->builtins()->JSBuiltinsConstructStub());
1787
1788 native_context->sloppy_generator_function_map()
1789 ->set_constructor_or_backpointer(*generator_function_function);
1790 native_context->strict_generator_function_map()
1791 ->set_constructor_or_backpointer(*generator_function_function);
1792 native_context->strong_generator_function_map()
1793 ->set_constructor_or_backpointer(*generator_function_function);
1779 } 1794 }
1780 1795
1781 { // -- S e t I t e r a t o r 1796 { // -- S e t I t e r a t o r
1782 Handle<JSObject> set_iterator_prototype = 1797 Handle<JSObject> set_iterator_prototype =
1783 isolate->factory()->NewJSObject(isolate->object_function(), TENURED); 1798 isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
1784 SetObjectPrototype(set_iterator_prototype, iterator_prototype); 1799 SetObjectPrototype(set_iterator_prototype, iterator_prototype);
1785 Handle<JSFunction> set_iterator_function = InstallFunction( 1800 Handle<JSFunction> set_iterator_function = InstallFunction(
1786 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize, 1801 container, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize,
1787 set_iterator_prototype, Builtins::kIllegal); 1802 set_iterator_prototype, Builtins::kIllegal);
1788 native_context->set_set_iterator_map(set_iterator_function->initial_map()); 1803 native_context->set_set_iterator_map(set_iterator_function->initial_map());
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 } 3166 }
3152 3167
3153 3168
3154 // Called when the top-level V8 mutex is destroyed. 3169 // Called when the top-level V8 mutex is destroyed.
3155 void Bootstrapper::FreeThreadResources() { 3170 void Bootstrapper::FreeThreadResources() {
3156 DCHECK(!IsActive()); 3171 DCHECK(!IsActive());
3157 } 3172 }
3158 3173
3159 } // namespace internal 3174 } // namespace internal
3160 } // namespace v8 3175 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.h » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698