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

Side by Side Diff: src/bootstrapper.cc

Issue 2705293004: Remove infrastructure for experimental JS natives (Closed)
Patch Set: Created 3 years, 10 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 DCHECK(source_code->is_short()); 49 DCHECK(source_code->is_short());
50 Source::GetSourceCache(heap)->set(index, *source_code); 50 Source::GetSourceCache(heap)->set(index, *source_code);
51 } 51 }
52 Handle<Object> cached_source(Source::GetSourceCache(heap)->get(index), 52 Handle<Object> cached_source(Source::GetSourceCache(heap)->get(index),
53 isolate_); 53 isolate_);
54 return Handle<String>::cast(cached_source); 54 return Handle<String>::cast(cached_source);
55 } 55 }
56 56
57 57
58 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index); 58 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index);
59 template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>(
60 int index);
61 template Handle<String> Bootstrapper::SourceLookup<ExperimentalExtraNatives>( 59 template Handle<String> Bootstrapper::SourceLookup<ExperimentalExtraNatives>(
62 int index); 60 int index);
63 template Handle<String> Bootstrapper::SourceLookup<ExtraNatives>(int index); 61 template Handle<String> Bootstrapper::SourceLookup<ExtraNatives>(int index);
64 62
65 63
66 void Bootstrapper::Initialize(bool create_heap_objects) { 64 void Bootstrapper::Initialize(bool create_heap_objects) {
67 extensions_cache_.Initialize(isolate_, create_heap_objects); 65 extensions_cache_.Initialize(isolate_, create_heap_objects);
68 } 66 }
69 67
70 68
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ExternalOneByteString::cast(natives_source)->resource()); 123 ExternalOneByteString::cast(natives_source)->resource());
126 delete resource; 124 delete resource;
127 } 125 }
128 } 126 }
129 } 127 }
130 } 128 }
131 129
132 130
133 void Bootstrapper::TearDown() { 131 void Bootstrapper::TearDown() {
134 DeleteNativeSources(Natives::GetSourceCache(isolate_->heap())); 132 DeleteNativeSources(Natives::GetSourceCache(isolate_->heap()));
135 DeleteNativeSources(ExperimentalNatives::GetSourceCache(isolate_->heap()));
136 DeleteNativeSources(ExtraNatives::GetSourceCache(isolate_->heap())); 133 DeleteNativeSources(ExtraNatives::GetSourceCache(isolate_->heap()));
137 DeleteNativeSources( 134 DeleteNativeSources(
138 ExperimentalExtraNatives::GetSourceCache(isolate_->heap())); 135 ExperimentalExtraNatives::GetSourceCache(isolate_->heap()));
139 136
140 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical 137 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical
141 } 138 }
142 139
143 140
144 class Genesis BASE_EMBEDDED { 141 class Genesis BASE_EMBEDDED {
145 public: 142 public:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, 219 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target,
223 const char* name, Builtins::Name call, 220 const char* name, Builtins::Name call,
224 BuiltinFunctionId id); 221 BuiltinFunctionId id);
225 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, 222 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target,
226 const char* name, 223 const char* name,
227 ElementsKind elements_kind); 224 ElementsKind elements_kind);
228 bool InstallNatives(GlobalContextType context_type); 225 bool InstallNatives(GlobalContextType context_type);
229 226
230 void InstallTypedArray(const char* name, ElementsKind elements_kind, 227 void InstallTypedArray(const char* name, ElementsKind elements_kind,
231 Handle<JSFunction>* fun); 228 Handle<JSFunction>* fun);
232 bool InstallExperimentalNatives();
233 bool InstallExtraNatives(); 229 bool InstallExtraNatives();
234 bool InstallExperimentalExtraNatives(); 230 bool InstallExperimentalExtraNatives();
235 bool InstallDebuggerNatives(); 231 bool InstallDebuggerNatives();
236 void InstallBuiltinFunctionIds(); 232 void InstallBuiltinFunctionIds();
237 void InstallExperimentalBuiltinFunctionIds(); 233 void InstallExperimentalBuiltinFunctionIds();
238 void InitializeNormalizedMapCaches(); 234 void InitializeNormalizedMapCaches();
239 235
240 enum ExtensionTraversalState { 236 enum ExtensionTraversalState {
241 UNVISITED, VISITED, INSTALLED 237 UNVISITED, VISITED, INSTALLED
242 }; 238 };
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2942 Handle<Object> global = isolate->global_object(); 2938 Handle<Object> global = isolate->global_object();
2943 Handle<Object> utils = isolate->natives_utils_object(); 2939 Handle<Object> utils = isolate->natives_utils_object();
2944 Handle<Object> extras_utils = isolate->extras_utils_object(); 2940 Handle<Object> extras_utils = isolate->extras_utils_object();
2945 Handle<Object> args[] = {global, utils, extras_utils}; 2941 Handle<Object> args[] = {global, utils, extras_utils};
2946 2942
2947 return Bootstrapper::CompileNative(isolate, name, source_code, 2943 return Bootstrapper::CompileNative(isolate, name, source_code,
2948 arraysize(args), args, NATIVES_CODE); 2944 arraysize(args), args, NATIVES_CODE);
2949 } 2945 }
2950 2946
2951 2947
2952 bool Bootstrapper::CompileExperimentalBuiltin(Isolate* isolate, int index) {
2953 HandleScope scope(isolate);
2954 Vector<const char> name = ExperimentalNatives::GetScriptName(index);
2955 Handle<String> source_code =
2956 isolate->bootstrapper()->SourceLookup<ExperimentalNatives>(index);
2957 Handle<Object> global = isolate->global_object();
2958 Handle<Object> utils = isolate->natives_utils_object();
2959 Handle<Object> args[] = {global, utils};
2960 return Bootstrapper::CompileNative(isolate, name, source_code,
2961 arraysize(args), args, NATIVES_CODE);
2962 }
2963
2964
2965 bool Bootstrapper::CompileExtraBuiltin(Isolate* isolate, int index) { 2948 bool Bootstrapper::CompileExtraBuiltin(Isolate* isolate, int index) {
2966 HandleScope scope(isolate); 2949 HandleScope scope(isolate);
2967 Vector<const char> name = ExtraNatives::GetScriptName(index); 2950 Vector<const char> name = ExtraNatives::GetScriptName(index);
2968 Handle<String> source_code = 2951 Handle<String> source_code =
2969 isolate->bootstrapper()->SourceLookup<ExtraNatives>(index); 2952 isolate->bootstrapper()->SourceLookup<ExtraNatives>(index);
2970 Handle<Object> global = isolate->global_object(); 2953 Handle<Object> global = isolate->global_object();
2971 Handle<Object> binding = isolate->extras_binding_object(); 2954 Handle<Object> binding = isolate->extras_binding_object();
2972 Handle<Object> extras_utils = isolate->extras_utils_object(); 2955 Handle<Object> extras_utils = isolate->extras_utils_object();
2973 Handle<Object> args[] = {global, binding, extras_utils}; 2956 Handle<Object> args[] = {global, binding, extras_utils};
2974 return Bootstrapper::CompileNative(isolate, name, source_code, 2957 return Bootstrapper::CompileNative(isolate, name, source_code,
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4211 Handle<Map> map(native_context()->strict_arguments_map()); 4194 Handle<Map> map(native_context()->strict_arguments_map());
4212 Map::EnsureDescriptorSlack(map, 1); 4195 Map::EnsureDescriptorSlack(map, 1);
4213 map->AppendDescriptor(&d); 4196 map->AppendDescriptor(&d);
4214 } 4197 }
4215 } 4198 }
4216 4199
4217 return true; 4200 return true;
4218 } 4201 }
4219 4202
4220 4203
4221 bool Genesis::InstallExperimentalNatives() {
4222 static const char* harmony_tailcalls_natives[] = {nullptr};
4223 static const char* harmony_sharedarraybuffer_natives[] = {nullptr};
4224 static const char* harmony_do_expressions_natives[] = {nullptr};
4225 static const char* harmony_regexp_lookbehind_natives[] = {nullptr};
4226 static const char* harmony_regexp_named_captures_natives[] = {nullptr};
4227 static const char* harmony_regexp_property_natives[] = {nullptr};
4228 static const char* harmony_function_sent_natives[] = {nullptr};
4229 static const char* harmony_array_prototype_values_natives[] = {nullptr};
4230 #ifdef V8_I18N_SUPPORT
4231 static const char* icu_case_mapping_natives[] = {nullptr};
4232 static const char* datetime_format_to_parts_natives[] = {nullptr};
4233 #endif
4234 static const char* harmony_restrictive_generators_natives[] = {nullptr};
4235 static const char* harmony_trailing_commas_natives[] = {nullptr};
4236 static const char* harmony_function_tostring_natives[] = {nullptr};
4237 static const char* harmony_class_fields_natives[] = {nullptr};
4238 static const char* harmony_object_rest_spread_natives[] = {nullptr};
4239 static const char* harmony_async_iteration_natives[] = {nullptr};
4240 static const char* harmony_dynamic_import_natives[] = {nullptr};
4241 static const char* harmony_promise_finally_natives[] = {nullptr};
4242
4243 for (int i = ExperimentalNatives::GetDebuggerCount();
4244 i < ExperimentalNatives::GetBuiltinsCount(); i++) {
4245 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \
4246 if (FLAG_##id) { \
4247 for (size_t j = 0; id##_natives[j] != NULL; j++) { \
4248 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \
4249 if (strncmp(script_name.start(), id##_natives[j], \
4250 script_name.length()) == 0) { \
4251 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \
4252 return false; \
4253 } \
4254 } \
4255 } \
4256 }
4257 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES);
4258 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES);
4259 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES);
4260 #undef INSTALL_EXPERIMENTAL_NATIVES
4261 }
4262
4263 if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false;
4264
4265 InstallExperimentalBuiltinFunctionIds();
4266 return true;
4267 }
4268
4269
4270 bool Genesis::InstallExtraNatives() { 4204 bool Genesis::InstallExtraNatives() {
4271 HandleScope scope(isolate()); 4205 HandleScope scope(isolate());
4272 4206
4273 Handle<JSObject> extras_binding = 4207 Handle<JSObject> extras_binding =
4274 factory()->NewJSObject(isolate()->object_function()); 4208 factory()->NewJSObject(isolate()->object_function());
4275 native_context()->set_extras_binding_object(*extras_binding); 4209 native_context()->set_extras_binding_object(*extras_binding);
4276 4210
4277 for (int i = ExtraNatives::GetDebuggerCount(); 4211 for (int i = ExtraNatives::GetDebuggerCount();
4278 i < ExtraNatives::GetBuiltinsCount(); i++) { 4212 i < ExtraNatives::GetBuiltinsCount(); i++) {
4279 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false; 4213 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4329 const BuiltinFunctionIds builtins[] = { 4263 const BuiltinFunctionIds builtins[] = {
4330 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; 4264 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)};
4331 4265
4332 for (const BuiltinFunctionIds& builtin : builtins) { 4266 for (const BuiltinFunctionIds& builtin : builtins) {
4333 Handle<JSObject> holder = 4267 Handle<JSObject> holder =
4334 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); 4268 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr);
4335 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); 4269 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id);
4336 } 4270 }
4337 } 4271 }
4338 4272
4339
4340 void Genesis::InstallExperimentalBuiltinFunctionIds() {
4341 if (FLAG_harmony_sharedarraybuffer) {
4342 struct BuiltinFunctionIds {
4343 const char* holder_expr;
4344 const char* fun_name;
4345 BuiltinFunctionId id;
4346 };
4347
4348 const BuiltinFunctionIds atomic_builtins[] = {
4349 ATOMIC_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)};
4350
4351 for (const BuiltinFunctionIds& builtin : atomic_builtins) {
4352 Handle<JSObject> holder =
4353 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr);
4354 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id);
4355 }
4356 }
4357 }
4358
4359 #undef INSTALL_BUILTIN_ID 4273 #undef INSTALL_BUILTIN_ID
4360 4274
4361 4275
4362 void Genesis::InitializeNormalizedMapCaches() { 4276 void Genesis::InitializeNormalizedMapCaches() {
4363 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate()); 4277 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate());
4364 native_context()->set_normalized_map_cache(*cache); 4278 native_context()->set_normalized_map_cache(*cache);
4365 } 4279 }
4366 4280
4367 4281
4368 bool Bootstrapper::InstallExtensions(Handle<Context> native_context, 4282 bool Bootstrapper::InstallExtensions(Handle<Context> native_context,
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
4858 4772
4859 isolate->counters()->contexts_created_from_scratch()->Increment(); 4773 isolate->counters()->contexts_created_from_scratch()->Increment();
4860 } 4774 }
4861 4775
4862 // Install experimental natives. Do not include them into the 4776 // Install experimental natives. Do not include them into the
4863 // snapshot as we should be able to turn them off at runtime. Re-installing 4777 // snapshot as we should be able to turn them off at runtime. Re-installing
4864 // them after they have already been deserialized would also fail. 4778 // them after they have already been deserialized would also fail.
4865 if (context_type == FULL_CONTEXT) { 4779 if (context_type == FULL_CONTEXT) {
4866 if (!isolate->serializer_enabled()) { 4780 if (!isolate->serializer_enabled()) {
4867 InitializeExperimentalGlobal(); 4781 InitializeExperimentalGlobal();
4868 if (!InstallExperimentalNatives()) return;
4869 4782
4870 if (FLAG_experimental_extras) { 4783 if (FLAG_experimental_extras) {
4871 if (!InstallExperimentalExtraNatives()) return; 4784 if (!InstallExperimentalExtraNatives()) return;
4872 } 4785 }
4873 4786
4874 // Store String.prototype's map again in case it has been changed by 4787 // Store String.prototype's map again in case it has been changed by
4875 // experimental natives. 4788 // experimental natives.
4876 Handle<JSFunction> string_function(native_context()->string_function()); 4789 Handle<JSFunction> string_function(native_context()->string_function());
4877 JSObject* string_function_prototype = 4790 JSObject* string_function_prototype =
4878 JSObject::cast(string_function->initial_map()->prototype()); 4791 JSObject::cast(string_function->initial_map()->prototype());
4879 DCHECK(string_function_prototype->HasFastProperties()); 4792 DCHECK(string_function_prototype->HasFastProperties());
4880 native_context()->set_string_function_prototype_map( 4793 native_context()->set_string_function_prototype_map(
4881 string_function_prototype->map()); 4794 string_function_prototype->map());
4882 } 4795 }
4883 // The serializer cannot serialize typed arrays. Reset those typed arrays
4884 // for each new context.
4885 } else if (context_type == DEBUG_CONTEXT) { 4796 } else if (context_type == DEBUG_CONTEXT) {
4886 DCHECK(!isolate->serializer_enabled()); 4797 DCHECK(!isolate->serializer_enabled());
4887 InitializeExperimentalGlobal(); 4798 InitializeExperimentalGlobal();
4888 if (!InstallDebuggerNatives()) return; 4799 if (!InstallDebuggerNatives()) return;
4889 } 4800 }
4890 4801
4891 ConfigureUtilsObject(context_type); 4802 ConfigureUtilsObject(context_type);
4892 4803
4893 // Check that the script context table is empty except for the 'this' binding. 4804 // Check that the script context table is empty except for the 'this' binding.
4894 // We do not need script contexts for native scripts. 4805 // We do not need script contexts for native scripts.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 } 4898 }
4988 4899
4989 4900
4990 // Called when the top-level V8 mutex is destroyed. 4901 // Called when the top-level V8 mutex is destroyed.
4991 void Bootstrapper::FreeThreadResources() { 4902 void Bootstrapper::FreeThreadResources() {
4992 DCHECK(!IsActive()); 4903 DCHECK(!IsActive());
4993 } 4904 }
4994 4905
4995 } // namespace internal 4906 } // namespace internal
4996 } // namespace v8 4907 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/heap/heap.h » ('j') | src/js/prologue.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698