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

Side by Side Diff: src/bootstrapper.cc

Issue 1282793002: Debugger: load debugger builtins as normal native JS. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use InstallFunctions and InstallConstants Created 5 years, 4 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/bootstrapper.h ('k') | src/debug/debug.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/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, 233 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target,
234 const char* name, 234 const char* name,
235 ElementsKind elements_kind); 235 ElementsKind elements_kind);
236 bool InstallNatives(ContextType context_type); 236 bool InstallNatives(ContextType context_type);
237 237
238 void InstallTypedArray(const char* name, ElementsKind elements_kind, 238 void InstallTypedArray(const char* name, ElementsKind elements_kind,
239 Handle<JSFunction>* fun); 239 Handle<JSFunction>* fun);
240 bool InstallExperimentalNatives(); 240 bool InstallExperimentalNatives();
241 bool InstallExtraNatives(); 241 bool InstallExtraNatives();
242 bool InstallDebuggerNatives();
242 void InstallBuiltinFunctionIds(); 243 void InstallBuiltinFunctionIds();
243 void InstallExperimentalBuiltinFunctionIds(); 244 void InstallExperimentalBuiltinFunctionIds();
244 void InitializeNormalizedMapCaches(); 245 void InitializeNormalizedMapCaches();
245 246
246 enum ExtensionTraversalState { 247 enum ExtensionTraversalState {
247 UNVISITED, VISITED, INSTALLED 248 UNVISITED, VISITED, INSTALLED
248 }; 249 };
249 250
250 class ExtensionStates { 251 class ExtensionStates {
251 public: 252 public:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 348
348 Handle<Context> Bootstrapper::CreateEnvironment( 349 Handle<Context> Bootstrapper::CreateEnvironment(
349 MaybeHandle<JSGlobalProxy> maybe_global_proxy, 350 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
350 v8::Local<v8::ObjectTemplate> global_proxy_template, 351 v8::Local<v8::ObjectTemplate> global_proxy_template,
351 v8::ExtensionConfiguration* extensions, ContextType context_type) { 352 v8::ExtensionConfiguration* extensions, ContextType context_type) {
352 HandleScope scope(isolate_); 353 HandleScope scope(isolate_);
353 Genesis genesis(isolate_, maybe_global_proxy, global_proxy_template, 354 Genesis genesis(isolate_, maybe_global_proxy, global_proxy_template,
354 extensions, context_type); 355 extensions, context_type);
355 Handle<Context> env = genesis.result(); 356 Handle<Context> env = genesis.result();
356 if (env.is_null() || 357 if (env.is_null() ||
357 (context_type == FULL_CONTEXT && !InstallExtensions(env, extensions))) { 358 (context_type != THIN_CONTEXT && !InstallExtensions(env, extensions))) {
358 return Handle<Context>(); 359 return Handle<Context>();
359 } 360 }
360 return scope.CloseAndEscape(env); 361 return scope.CloseAndEscape(env);
361 } 362 }
362 363
363 364
364 bool Bootstrapper::CreateCodeStubContext(Isolate* isolate) { 365 bool Bootstrapper::CreateCodeStubContext(Isolate* isolate) {
365 HandleScope scope(isolate); 366 HandleScope scope(isolate);
366 SaveContext save_context(isolate); 367 SaveContext save_context(isolate);
367 BootstrapperActive active(this); 368 BootstrapperActive active(this);
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 bool Genesis::InstallExtraNatives() { 2613 bool Genesis::InstallExtraNatives() {
2613 for (int i = ExtraNatives::GetDebuggerCount(); 2614 for (int i = ExtraNatives::GetDebuggerCount();
2614 i < ExtraNatives::GetBuiltinsCount(); i++) { 2615 i < ExtraNatives::GetBuiltinsCount(); i++) {
2615 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false; 2616 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false;
2616 } 2617 }
2617 2618
2618 return true; 2619 return true;
2619 } 2620 }
2620 2621
2621 2622
2623 bool Genesis::InstallDebuggerNatives() {
2624 for (int i = 0; i < Natives::GetDebuggerCount(); ++i) {
2625 if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false;
2626 }
2627 return CallUtilsFunction(isolate(), "PostDebug");
2628 }
2629
2630
2622 bool Bootstrapper::InstallCodeStubNatives(Isolate* isolate) { 2631 bool Bootstrapper::InstallCodeStubNatives(Isolate* isolate) {
2623 for (int i = CodeStubNatives::GetDebuggerCount(); 2632 for (int i = CodeStubNatives::GetDebuggerCount();
2624 i < CodeStubNatives::GetBuiltinsCount(); i++) { 2633 i < CodeStubNatives::GetBuiltinsCount(); i++) {
2625 if (!CompileCodeStubBuiltin(isolate, i)) return false; 2634 if (!CompileCodeStubBuiltin(isolate, i)) return false;
2626 } 2635 }
2627 2636
2628 return true; 2637 return true;
2629 } 2638 }
2630 2639
2631 2640
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 Handle<JSGlobalObject> global(JSGlobalObject::cast( 2722 Handle<JSGlobalObject> global(JSGlobalObject::cast(
2714 native_context->global_object())); 2723 native_context->global_object()));
2715 2724
2716 Handle<JSObject> Error = Handle<JSObject>::cast( 2725 Handle<JSObject> Error = Handle<JSObject>::cast(
2717 Object::GetProperty(isolate, global, "Error").ToHandleChecked()); 2726 Object::GetProperty(isolate, global, "Error").ToHandleChecked());
2718 Handle<String> name = 2727 Handle<String> name =
2719 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("stackTraceLimit")); 2728 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("stackTraceLimit"));
2720 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate); 2729 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
2721 JSObject::AddProperty(Error, name, stack_trace_limit, NONE); 2730 JSObject::AddProperty(Error, name, stack_trace_limit, NONE);
2722 2731
2723 // By now the utils object is useless and can be removed.
2724 native_context->set_natives_utils_object(*factory->undefined_value());
2725
2726 // Expose the natives in global if a name for it is specified. 2732 // Expose the natives in global if a name for it is specified.
2727 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { 2733 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
2728 Handle<String> natives_key = 2734 Handle<String> natives_key =
2729 factory->InternalizeUtf8String(FLAG_expose_natives_as); 2735 factory->InternalizeUtf8String(FLAG_expose_natives_as);
2730 uint32_t dummy_index; 2736 uint32_t dummy_index;
2731 if (natives_key->AsArrayIndex(&dummy_index)) return true; 2737 if (natives_key->AsArrayIndex(&dummy_index)) return true;
2732 Handle<JSBuiltinsObject> natives(global->builtins()); 2738 Handle<JSBuiltinsObject> natives(global->builtins());
2733 JSObject::AddProperty(global, natives_key, natives, DONT_ENUM); 2739 JSObject::AddProperty(global, natives_key, natives, DONT_ENUM);
2734 } 2740 }
2735 2741
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
3196 Handle<GlobalObject> global_object = 3202 Handle<GlobalObject> global_object =
3197 CreateNewGlobals(global_proxy_template, global_proxy); 3203 CreateNewGlobals(global_proxy_template, global_proxy);
3198 HookUpGlobalProxy(global_object, global_proxy); 3204 HookUpGlobalProxy(global_object, global_proxy);
3199 InitializeGlobal(global_object, empty_function, context_type); 3205 InitializeGlobal(global_object, empty_function, context_type);
3200 InitializeNormalizedMapCaches(); 3206 InitializeNormalizedMapCaches();
3201 3207
3202 if (!InstallNatives(context_type)) return; 3208 if (!InstallNatives(context_type)) return;
3203 3209
3204 MakeFunctionInstancePrototypeWritable(); 3210 MakeFunctionInstancePrototypeWritable();
3205 3211
3206 if (context_type == FULL_CONTEXT) { 3212 if (context_type != THIN_CONTEXT) {
3207 if (!ConfigureGlobalObjects(global_proxy_template)) return; 3213 if (!ConfigureGlobalObjects(global_proxy_template)) return;
3208 } 3214 }
3209 isolate->counters()->contexts_created_from_scratch()->Increment(); 3215 isolate->counters()->contexts_created_from_scratch()->Increment();
3210 } 3216 }
3211 3217
3212 // Install experimental and extra natives. Do not include them into the 3218 // Install experimental and extra natives. Do not include them into the
3213 // snapshot as we should be able to turn them off at runtime. Re-installing 3219 // snapshot as we should be able to turn them off at runtime. Re-installing
3214 // them after they have already been deserialized would also fail. 3220 // them after they have already been deserialized would also fail.
3215 if (context_type == FULL_CONTEXT) { 3221 if (context_type == FULL_CONTEXT) {
3216 if (!isolate->serializer_enabled()) { 3222 if (!isolate->serializer_enabled()) {
3217 InitializeExperimentalGlobal(); 3223 InitializeExperimentalGlobal();
3218 if (!InstallExperimentalNatives()) return; 3224 if (!InstallExperimentalNatives()) return;
3219 if (!InstallExtraNatives()) return; 3225 if (!InstallExtraNatives()) return;
3226 // By now the utils object is useless and can be removed.
3227 native_context()->set_natives_utils_object(
3228 isolate->heap()->undefined_value());
3220 } 3229 }
3221 3230
3222 // The serializer cannot serialize typed arrays. Reset those typed arrays 3231 // The serializer cannot serialize typed arrays. Reset those typed arrays
3223 // for each new context. 3232 // for each new context.
3224 InitializeBuiltinTypedArrays(); 3233 InitializeBuiltinTypedArrays();
3234 } else if (context_type == DEBUG_CONTEXT) {
3235 DCHECK(!isolate->serializer_enabled());
3236 InitializeExperimentalGlobal();
3237 if (!InstallDebuggerNatives()) return;
3225 } 3238 }
3226 3239
3227 result_ = native_context(); 3240 result_ = native_context();
3228 } 3241 }
3229 3242
3230 3243
3231 // Support for thread preemption. 3244 // Support for thread preemption.
3232 3245
3233 // Reserve space for statics needing saving and restoring. 3246 // Reserve space for statics needing saving and restoring.
3234 int Bootstrapper::ArchiveSpacePerThread() { 3247 int Bootstrapper::ArchiveSpacePerThread() {
(...skipping 16 matching lines...) Expand all
3251 } 3264 }
3252 3265
3253 3266
3254 // Called when the top-level V8 mutex is destroyed. 3267 // Called when the top-level V8 mutex is destroyed.
3255 void Bootstrapper::FreeThreadResources() { 3268 void Bootstrapper::FreeThreadResources() {
3256 DCHECK(!IsActive()); 3269 DCHECK(!IsActive());
3257 } 3270 }
3258 3271
3259 } // namespace internal 3272 } // namespace internal
3260 } // namespace v8 3273 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/debug/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698