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

Unified Diff: src/bootstrapper.cc

Issue 138143014: Robustified extension installation a bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index d039ac06ad7606224549f8b268c32e8dc52e91fc..288cac20a81d7c045abac75564c4a48e7d726bfd 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -102,9 +102,7 @@ void Bootstrapper::Initialize(bool create_heap_objects) {
void Bootstrapper::InitializeOncePerProcess() {
-#ifdef ADDRESS_SANITIZER
FreeBufferExtension::Register();
-#endif
GCExtension::Register();
ExternalizeStringExtension::Register();
StatisticsExtension::Register();
@@ -238,13 +236,18 @@ class Genesis BASE_EMBEDDED {
// provided.
static bool InstallExtensions(Handle<Context> native_context,
v8::ExtensionConfiguration* extensions);
+ static bool InstallAutoExtensions(Isolate* isolate,
+ ExtensionStates* extension_states);
+ static bool InstallRequestedExtensions(Isolate* isolate,
+ v8::ExtensionConfiguration* extensions,
+ ExtensionStates* extension_states);
static bool InstallExtension(Isolate* isolate,
const char* name,
ExtensionStates* extension_states);
static bool InstallExtension(Isolate* isolate,
v8::RegisteredExtension* current,
ExtensionStates* extension_states);
- static void InstallSpecialObjects(Handle<Context> native_context);
+ static bool InstallSpecialObjects(Handle<Context> native_context);
bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
bool ConfigureApiObject(Handle<JSObject> object,
Handle<ObjectTemplateInfo> object_template);
@@ -2152,13 +2155,12 @@ bool Bootstrapper::InstallExtensions(Handle<Context> native_context,
BootstrapperActive active(this);
SaveContext saved_context(isolate_);
isolate_->set_context(*native_context);
- if (!Genesis::InstallExtensions(native_context, extensions)) return false;
- Genesis::InstallSpecialObjects(native_context);
- return true;
+ return Genesis::InstallExtensions(native_context, extensions) &&
+ Genesis::InstallSpecialObjects(native_context);
}
-void Genesis::InstallSpecialObjects(Handle<Context> native_context) {
+bool Genesis::InstallSpecialObjects(Handle<Context> native_context) {
Isolate* isolate = native_context->GetIsolate();
Factory* factory = isolate->factory();
HandleScope scope(isolate);
@@ -2168,11 +2170,9 @@ void Genesis::InstallSpecialObjects(Handle<Context> native_context) {
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
Handle<String> natives =
factory->InternalizeUtf8String(FLAG_expose_natives_as);
- CHECK_NOT_EMPTY_HANDLE(isolate,
- JSObject::SetLocalPropertyIgnoreAttributes(
- global, natives,
- Handle<JSObject>(global->builtins()),
- DONT_ENUM));
+ JSObject::SetLocalPropertyIgnoreAttributes(
+ global, natives, Handle<JSObject>(global->builtins()), DONT_ENUM);
+ if (isolate->has_pending_exception()) return false;
}
Handle<Object> Error = GetProperty(global, "Error");
@@ -2181,10 +2181,9 @@ void Genesis::InstallSpecialObjects(Handle<Context> native_context) {
STATIC_ASCII_VECTOR("stackTraceLimit"));
Handle<Smi> stack_trace_limit(
Smi::FromInt(FLAG_stack_trace_limit), isolate);
- CHECK_NOT_EMPTY_HANDLE(isolate,
- JSObject::SetLocalPropertyIgnoreAttributes(
- Handle<JSObject>::cast(Error), name,
- stack_trace_limit, NONE));
+ JSObject::SetLocalPropertyIgnoreAttributes(
+ Handle<JSObject>::cast(Error), name, stack_trace_limit, NONE);
+ if (isolate->has_pending_exception()) return false;
}
#ifdef ENABLE_DEBUGGER_SUPPORT
@@ -2193,7 +2192,7 @@ void Genesis::InstallSpecialObjects(Handle<Context> native_context) {
Debug* debug = isolate->debug();
// If loading fails we just bail out without installing the
// debugger but without tanking the whole context.
- if (!debug->Load()) return;
+ if (!debug->Load()) return true;
// Set the security token for the debugger context to the same as
// the shell native context to allow calling between these (otherwise
// exposing debug global object doesn't make much sense).
@@ -2204,11 +2203,12 @@ void Genesis::InstallSpecialObjects(Handle<Context> native_context) {
factory->InternalizeUtf8String(FLAG_expose_debug_as);
Handle<Object> global_proxy(
debug->debug_context()->global_proxy(), isolate);
- CHECK_NOT_EMPTY_HANDLE(isolate,
- JSObject::SetLocalPropertyIgnoreAttributes(
- global, debug_string, global_proxy, DONT_ENUM));
+ JSObject::SetLocalPropertyIgnoreAttributes(
+ global, debug_string, global_proxy, DONT_ENUM);
+ if (isolate->has_pending_exception()) return false;
}
#endif
+ return true;
}
@@ -2240,38 +2240,46 @@ void Genesis::ExtensionStates::set_state(RegisteredExtension* extension,
reinterpret_cast<void*>(static_cast<intptr_t>(state));
}
+
bool Genesis::InstallExtensions(Handle<Context> native_context,
v8::ExtensionConfiguration* extensions) {
Isolate* isolate = native_context->GetIsolate();
ExtensionStates extension_states; // All extensions have state UNVISITED.
- // Install auto extensions.
- v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
- while (current != NULL) {
- if (current->extension()->auto_enable())
- InstallExtension(isolate, current, &extension_states);
- current = current->next();
+ return InstallAutoExtensions(isolate, &extension_states) &&
+ (!FLAG_expose_free_buffer ||
+ InstallExtension(isolate, "v8/free-buffer", &extension_states)) &&
+ (!FLAG_expose_gc ||
+ InstallExtension(isolate, "v8/gc", &extension_states)) &&
+ (!FLAG_expose_externalize_string ||
+ InstallExtension(isolate, "v8/externalize", &extension_states)) &&
+ (!FLAG_track_gc_object_stats ||
+ InstallExtension(isolate, "v8/statistics", &extension_states)) &&
+ (!FLAG_expose_trigger_failure ||
+ InstallExtension(isolate, "v8/trigger-failure", &extension_states)) &&
+ InstallRequestedExtensions(isolate, extensions, &extension_states);
+}
+
+
+bool Genesis::InstallAutoExtensions(Isolate* isolate,
+ ExtensionStates* extension_states) {
+ for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension();
+ it != NULL;
+ it = it->next()) {
+ if (it->extension()->auto_enable() &&
+ !InstallExtension(isolate, it, extension_states)) {
+ return false;
+ }
}
+ return true;
+}
-#ifdef ADDRESS_SANITIZER
- if (FLAG_expose_free_buffer) {
- InstallExtension(isolate, "v8/free-buffer", &extension_states);
- }
-#endif
- if (FLAG_expose_gc) InstallExtension(isolate, "v8/gc", &extension_states);
- if (FLAG_expose_externalize_string) {
- InstallExtension(isolate, "v8/externalize", &extension_states);
- }
- if (FLAG_track_gc_object_stats) {
- InstallExtension(isolate, "v8/statistics", &extension_states);
- }
- if (FLAG_expose_trigger_failure) {
- InstallExtension(isolate, "v8/trigger-failure", &extension_states);
- }
+bool Genesis::InstallRequestedExtensions(Isolate* isolate,
+ v8::ExtensionConfiguration* extensions,
+ ExtensionStates* extension_states) {
for (const char** it = extensions->begin(); it != extensions->end(); ++it) {
- if (!InstallExtension(isolate, *it, &extension_states)) return false;
+ if (!InstallExtension(isolate, *it, extension_states)) return false;
}
-
return true;
}
@@ -2281,19 +2289,16 @@ bool Genesis::InstallExtensions(Handle<Context> native_context,
bool Genesis::InstallExtension(Isolate* isolate,
const char* name,
ExtensionStates* extension_states) {
- v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
- // Loop until we find the relevant extension
- while (current != NULL) {
- if (strcmp(name, current->extension()->name()) == 0) break;
- current = current->next();
- }
- // Didn't find the extension; fail.
- if (!Utils::ApiCheck(current != NULL,
- "v8::Context::New()",
- "Cannot find required extension")) {
- return false;
+ for (v8::RegisteredExtension* it = v8::RegisteredExtension::first_extension();
+ it != NULL;
+ it = it->next()) {
+ if (strcmp(name, it->extension()->name()) == 0) {
+ return InstallExtension(isolate, it, extension_states);
+ }
}
- return InstallExtension(isolate, current, extension_states);
+ return Utils::ApiCheck(false,
+ "v8::Context::New()",
+ "Cannot find required extension");
}
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698