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

Side by Side Diff: src/bootstrapper.cc

Issue 573018: * Generate contexts involving extensions using partial snapshots. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // processing callbacks which may create new environments. 312 // processing callbacks which may create new environments.
313 Genesis* previous_; 313 Genesis* previous_;
314 static Genesis* current_; 314 static Genesis* current_;
315 315
316 Handle<Context> global_context() { return global_context_; } 316 Handle<Context> global_context() { return global_context_; }
317 317
318 void CreateRoots(v8::Handle<v8::ObjectTemplate> global_template, 318 void CreateRoots(v8::Handle<v8::ObjectTemplate> global_template,
319 Handle<Object> global_object); 319 Handle<Object> global_object);
320 void InstallNativeFunctions(); 320 void InstallNativeFunctions();
321 bool InstallNatives(); 321 bool InstallNatives();
322 bool InstallExtensions(v8::ExtensionConfiguration* extensions); 322 static bool InstallExtensions(Handle<Context> global_context,
323 bool InstallExtension(const char* name); 323 v8::ExtensionConfiguration* extensions);
324 bool InstallExtension(v8::RegisteredExtension* current); 324 static bool InstallExtension(const char* name);
325 bool InstallSpecialObjects(); 325 static bool InstallExtension(v8::RegisteredExtension* current);
326 static void InstallSpecialObjects(Handle<Context> global_context);
326 bool ConfigureApiObject(Handle<JSObject> object, 327 bool ConfigureApiObject(Handle<JSObject> object,
327 Handle<ObjectTemplateInfo> object_template); 328 Handle<ObjectTemplateInfo> object_template);
328 bool ConfigureGlobalObjects(v8::Handle<v8::ObjectTemplate> global_template); 329 bool ConfigureGlobalObjects(v8::Handle<v8::ObjectTemplate> global_template);
329 330
330 // Migrates all properties from the 'from' object to the 'to' 331 // Migrates all properties from the 'from' object to the 'to'
331 // object and overrides the prototype in 'to' with the one from 332 // object and overrides the prototype in 'to' with the one from
332 // 'from'. 333 // 'from'.
333 void TransferObject(Handle<JSObject> from, Handle<JSObject> to); 334 void TransferObject(Handle<JSObject> from, Handle<JSObject> to);
334 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to); 335 void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to);
335 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to); 336 void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
336 337
337 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor( 338 Handle<DescriptorArray> ComputeFunctionInstanceDescriptor(
338 bool make_prototype_read_only, 339 bool make_prototype_read_only,
339 bool make_prototype_enumerable = false); 340 bool make_prototype_enumerable = false);
340 void MakeFunctionInstancePrototypeWritable(); 341 void MakeFunctionInstancePrototypeWritable();
341 342
342 void AddSpecialFunction(Handle<JSObject> prototype, 343 void AddSpecialFunction(Handle<JSObject> prototype,
343 const char* name, 344 const char* name,
344 Handle<Code> code); 345 Handle<Code> code);
345 346
346 void BuildSpecialFunctionTable(); 347 void BuildSpecialFunctionTable();
347 348
348 static bool CompileBuiltin(int index); 349 static bool CompileBuiltin(int index);
349 static bool CompileNative(Vector<const char> name, Handle<String> source); 350 static bool CompileNative(Vector<const char> name, Handle<String> source);
350 static bool CompileScriptCached(Vector<const char> name, 351 static bool CompileScriptCached(Vector<const char> name,
351 Handle<String> source, 352 Handle<String> source,
352 SourceCodeCache* cache, 353 SourceCodeCache* cache,
353 v8::Extension* extension, 354 v8::Extension* extension,
355 Handle<Context> top_context,
354 bool use_runtime_context); 356 bool use_runtime_context);
355 357
356 Handle<Context> result_; 358 Handle<Context> result_;
359 friend class Bootstrapper;
357 }; 360 };
358 361
359 Genesis* Genesis::current_ = NULL; 362 Genesis* Genesis::current_ = NULL;
360 363
361 364
362 void Bootstrapper::Iterate(ObjectVisitor* v) { 365 void Bootstrapper::Iterate(ObjectVisitor* v) {
363 extensions_cache.Iterate(v); 366 extensions_cache.Iterate(v);
364 v->Synchronize("Extensions"); 367 v->Synchronize("Extensions");
365 PendingFixups::Iterate(v); 368 PendingFixups::Iterate(v);
366 v->Synchronize("PendingFixups"); 369 v->Synchronize("PendingFixups");
367 } 370 }
368 371
369 372
370 // While setting up the environment, we collect code positions that 373 // While setting up the environment, we collect code positions that
371 // need to be patched before we can run any code in the environment. 374 // need to be patched before we can run any code in the environment.
372 void Bootstrapper::AddFixup(Code* code, MacroAssembler* masm) { 375 void Bootstrapper::AddFixup(Code* code, MacroAssembler* masm) {
373 PendingFixups::Add(code, masm); 376 PendingFixups::Add(code, masm);
374 } 377 }
375 378
376 379
377 bool Bootstrapper::IsActive() { 380 bool Bootstrapper::IsActive() {
378 return Genesis::current() != NULL; 381 return active_ != 0 || Genesis::current() != NULL;
Mads Ager (chromium) 2010/02/05 08:57:09 Can we get rid of the Genesis::current() check and
379 } 382 }
380 383
381 384
382 Handle<Context> Bootstrapper::CreateEnvironment( 385 Handle<Context> Bootstrapper::CreateEnvironment(
383 Handle<Object> global_object, 386 Handle<Object> global_object,
384 v8::Handle<v8::ObjectTemplate> global_template, 387 v8::Handle<v8::ObjectTemplate> global_template,
385 v8::ExtensionConfiguration* extensions) { 388 v8::ExtensionConfiguration* extensions) {
389 HandleScope scope;
386 Genesis genesis(global_object, global_template, extensions); 390 Genesis genesis(global_object, global_template, extensions);
391 if (!genesis.result().is_null()) {
392 if (!InstallExtensions(genesis.result(), extensions)) {
393 return Handle<Context>();
394 }
395 }
387 return genesis.result(); 396 return genesis.result();
388 } 397 }
389 398
390 399
391 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { 400 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
392 // object.__proto__ = proto; 401 // object.__proto__ = proto;
393 Handle<Map> old_to_map = Handle<Map>(object->map()); 402 Handle<Map> old_to_map = Handle<Map>(object->map());
394 Handle<Map> new_to_map = Factory::CopyMapDropTransitions(old_to_map); 403 Handle<Map> new_to_map = Factory::CopyMapDropTransitions(old_to_map);
395 new_to_map->set_prototype(*proto); 404 new_to_map->set_prototype(*proto);
396 object->set_map(*new_to_map); 405 object->set_map(*new_to_map);
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index); 902 Handle<String> source_code = Bootstrapper::NativesSourceLookup(index);
894 return CompileNative(name, source_code); 903 return CompileNative(name, source_code);
895 } 904 }
896 905
897 906
898 bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) { 907 bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) {
899 HandleScope scope; 908 HandleScope scope;
900 #ifdef ENABLE_DEBUGGER_SUPPORT 909 #ifdef ENABLE_DEBUGGER_SUPPORT
901 Debugger::set_compiling_natives(true); 910 Debugger::set_compiling_natives(true);
902 #endif 911 #endif
903 bool result = 912 bool result = CompileScriptCached(name,
904 CompileScriptCached(name, source, NULL, NULL, true); 913 source,
914 NULL,
915 NULL,
916 Handle<Context>(Top::context()),
917 true);
905 ASSERT(Top::has_pending_exception() != result); 918 ASSERT(Top::has_pending_exception() != result);
906 if (!result) Top::clear_pending_exception(); 919 if (!result) Top::clear_pending_exception();
907 #ifdef ENABLE_DEBUGGER_SUPPORT 920 #ifdef ENABLE_DEBUGGER_SUPPORT
908 Debugger::set_compiling_natives(false); 921 Debugger::set_compiling_natives(false);
909 #endif 922 #endif
910 return result; 923 return result;
911 } 924 }
912 925
913 926
914 bool Genesis::CompileScriptCached(Vector<const char> name, 927 bool Genesis::CompileScriptCached(Vector<const char> name,
915 Handle<String> source, 928 Handle<String> source,
916 SourceCodeCache* cache, 929 SourceCodeCache* cache,
917 v8::Extension* extension, 930 v8::Extension* extension,
931 Handle<Context> top_context,
918 bool use_runtime_context) { 932 bool use_runtime_context) {
919 HandleScope scope; 933 HandleScope scope;
920 Handle<JSFunction> boilerplate; 934 Handle<JSFunction> boilerplate;
921 935
922 // If we can't find the function in the cache, we compile a new 936 // If we can't find the function in the cache, we compile a new
923 // function and insert it into the cache. 937 // function and insert it into the cache.
924 if (cache == NULL || !cache->Lookup(name, &boilerplate)) { 938 if (cache == NULL || !cache->Lookup(name, &boilerplate)) {
925 ASSERT(source->IsAsciiRepresentation()); 939 ASSERT(source->IsAsciiRepresentation());
926 Handle<String> script_name = Factory::NewStringFromUtf8(name); 940 Handle<String> script_name = Factory::NewStringFromUtf8(name);
927 boilerplate = Compiler::Compile( 941 boilerplate = Compiler::Compile(
928 source, 942 source,
929 script_name, 943 script_name,
930 0, 944 0,
931 0, 945 0,
932 extension, 946 extension,
933 NULL, 947 NULL,
934 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); 948 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
935 if (boilerplate.is_null()) return false; 949 if (boilerplate.is_null()) return false;
936 if (cache != NULL) cache->Add(name, boilerplate); 950 if (cache != NULL) cache->Add(name, boilerplate);
937 } 951 }
938 952
939 // Setup the function context. Conceptually, we should clone the 953 // Setup the function context. Conceptually, we should clone the
940 // function before overwriting the context but since we're in a 954 // function before overwriting the context but since we're in a
941 // single-threaded environment it is not strictly necessary. 955 // single-threaded environment it is not strictly necessary.
942 ASSERT(Top::context()->IsGlobalContext()); 956 ASSERT(top_context->IsGlobalContext());
943 Handle<Context> context = 957 Handle<Context> context =
944 Handle<Context>(use_runtime_context 958 Handle<Context>(use_runtime_context
945 ? Top::context()->runtime_context() 959 ? Handle<Context>(top_context->runtime_context())
946 : Top::context()); 960 : top_context);
947 Handle<JSFunction> fun = 961 Handle<JSFunction> fun =
948 Factory::NewFunctionFromBoilerplate(boilerplate, context); 962 Factory::NewFunctionFromBoilerplate(boilerplate, context);
949 963
950 // Call function using either the runtime object or the global 964 // Call function using either the runtime object or the global
951 // object as the receiver. Provide no parameters. 965 // object as the receiver. Provide no parameters.
952 Handle<Object> receiver = 966 Handle<Object> receiver =
953 Handle<Object>(use_runtime_context 967 Handle<Object>(use_runtime_context
954 ? Top::context()->builtins() 968 ? top_context->builtins()
955 : Top::context()->global()); 969 : top_context->global());
956 bool has_pending_exception; 970 bool has_pending_exception;
957 Handle<Object> result = 971 Handle<Object> result =
958 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); 972 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
959 if (has_pending_exception) return false; 973 if (has_pending_exception) return false;
960 return PendingFixups::Process( 974 return PendingFixups::Process(
961 Handle<JSBuiltinsObject>(Top::context()->builtins())); 975 Handle<JSBuiltinsObject>(top_context->builtins()));
962 } 976 }
963 977
964 978
965 #define INSTALL_NATIVE(Type, name, var) \ 979 #define INSTALL_NATIVE(Type, name, var) \
966 Handle<String> var##_name = Factory::LookupAsciiSymbol(name); \ 980 Handle<String> var##_name = Factory::LookupAsciiSymbol(name); \
967 global_context()->set_##var(Type::cast(global_context()-> \ 981 global_context()->set_##var(Type::cast(global_context()-> \
968 builtins()-> \ 982 builtins()-> \
969 GetProperty(*var##_name))); 983 GetProperty(*var##_name)));
970 984
971 void Genesis::InstallNativeFunctions() { 985 void Genesis::InstallNativeFunctions() {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 } 1217 }
1204 1218
1205 #ifdef DEBUG 1219 #ifdef DEBUG
1206 builtins->Verify(); 1220 builtins->Verify();
1207 #endif 1221 #endif
1208 1222
1209 return true; 1223 return true;
1210 } 1224 }
1211 1225
1212 1226
1213 bool Genesis::InstallSpecialObjects() { 1227 int Bootstrapper::active_ = 0;
1228
1229
1230 bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
1231 v8::ExtensionConfiguration* extensions) {
1232 BootstrapperActive active;
1233 SaveContext saved_context;
1234 Top::set_context(*global_context);
1235 if (!Genesis::InstallExtensions(global_context, extensions)) return false;
1236 Genesis::InstallSpecialObjects(global_context);
1237 return true;
1238 }
1239
1240
1241 void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
1214 HandleScope scope; 1242 HandleScope scope;
1215 Handle<JSGlobalObject> js_global( 1243 Handle<JSGlobalObject> js_global(
1216 JSGlobalObject::cast(global_context()->global())); 1244 JSGlobalObject::cast(global_context->global()));
1217 // Expose the natives in global if a name for it is specified. 1245 // Expose the natives in global if a name for it is specified.
1218 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { 1246 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
1219 Handle<String> natives_string = 1247 Handle<String> natives_string =
1220 Factory::LookupAsciiSymbol(FLAG_expose_natives_as); 1248 Factory::LookupAsciiSymbol(FLAG_expose_natives_as);
1221 SetProperty(js_global, natives_string, 1249 SetProperty(js_global, natives_string,
1222 Handle<JSObject>(js_global->builtins()), DONT_ENUM); 1250 Handle<JSObject>(js_global->builtins()), DONT_ENUM);
1223 } 1251 }
1224 1252
1225 Handle<Object> Error = GetProperty(js_global, "Error"); 1253 Handle<Object> Error = GetProperty(js_global, "Error");
1226 if (Error->IsJSObject()) { 1254 if (Error->IsJSObject()) {
1227 Handle<String> name = Factory::LookupAsciiSymbol("stackTraceLimit"); 1255 Handle<String> name = Factory::LookupAsciiSymbol("stackTraceLimit");
1228 SetProperty(Handle<JSObject>::cast(Error), 1256 SetProperty(Handle<JSObject>::cast(Error),
1229 name, 1257 name,
1230 Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)), 1258 Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)),
1231 NONE); 1259 NONE);
1232 } 1260 }
1233 1261
1234 #ifdef ENABLE_DEBUGGER_SUPPORT 1262 #ifdef ENABLE_DEBUGGER_SUPPORT
1235 // Expose the debug global object in global if a name for it is specified. 1263 // Expose the debug global object in global if a name for it is specified.
1236 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { 1264 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
1237 // If loading fails we just bail out without installing the 1265 // If loading fails we just bail out without installing the
1238 // debugger but without tanking the whole context. 1266 // debugger but without tanking the whole context.
1239 if (!Debug::Load()) 1267 if (!Debug::Load())
Mads Ager (chromium) 2010/02/05 08:57:09 Either make this a one-liner or use braces around
1240 return true; 1268 return;
1241 // Set the security token for the debugger context to the same as 1269 // Set the security token for the debugger context to the same as
1242 // the shell global context to allow calling between these (otherwise 1270 // the shell global context to allow calling between these (otherwise
1243 // exposing debug global object doesn't make much sense). 1271 // exposing debug global object doesn't make much sense).
1244 Debug::debug_context()->set_security_token( 1272 Debug::debug_context()->set_security_token(
1245 global_context()->security_token()); 1273 global_context->security_token());
1246 1274
1247 Handle<String> debug_string = 1275 Handle<String> debug_string =
1248 Factory::LookupAsciiSymbol(FLAG_expose_debug_as); 1276 Factory::LookupAsciiSymbol(FLAG_expose_debug_as);
1249 SetProperty(js_global, debug_string, 1277 SetProperty(js_global, debug_string,
1250 Handle<Object>(Debug::debug_context()->global_proxy()), DONT_ENUM); 1278 Handle<Object>(Debug::debug_context()->global_proxy()), DONT_ENUM);
1251 } 1279 }
1252 #endif 1280 #endif
1253
1254 return true;
1255 } 1281 }
1256 1282
1257 1283
1258 bool Genesis::InstallExtensions(v8::ExtensionConfiguration* extensions) { 1284 bool Genesis::InstallExtensions(Handle<Context> global_context,
1285 v8::ExtensionConfiguration* extensions) {
1259 // Clear coloring of extension list 1286 // Clear coloring of extension list
1260 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension(); 1287 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
1261 while (current != NULL) { 1288 while (current != NULL) {
1262 current->set_state(v8::UNVISITED); 1289 current->set_state(v8::UNVISITED);
1263 current = current->next(); 1290 current = current->next();
1264 } 1291 }
1265 // Install auto extensions. Coordinate with AutoExtensionsExist below. 1292 // Install auto extensions.
1266 current = v8::RegisteredExtension::first_extension(); 1293 current = v8::RegisteredExtension::first_extension();
1267 while (current != NULL) { 1294 while (current != NULL) {
1268 if (current->extension()->auto_enable()) 1295 if (current->extension()->auto_enable())
1269 InstallExtension(current); 1296 InstallExtension(current);
1270 current = current->next(); 1297 current = current->next();
1271 } 1298 }
1272 1299
1273 if (FLAG_expose_gc) InstallExtension("v8/gc"); 1300 if (FLAG_expose_gc) InstallExtension("v8/gc");
1274 1301
1275 if (extensions == NULL) return true; 1302 if (extensions == NULL) return true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 current->set_state(v8::VISITED); 1346 current->set_state(v8::VISITED);
1320 v8::Extension* extension = current->extension(); 1347 v8::Extension* extension = current->extension();
1321 // Install the extension's dependencies 1348 // Install the extension's dependencies
1322 for (int i = 0; i < extension->dependency_count(); i++) { 1349 for (int i = 0; i < extension->dependency_count(); i++) {
1323 if (!InstallExtension(extension->dependencies()[i])) return false; 1350 if (!InstallExtension(extension->dependencies()[i])) return false;
1324 } 1351 }
1325 Vector<const char> source = CStrVector(extension->source()); 1352 Vector<const char> source = CStrVector(extension->source());
1326 Handle<String> source_code = Factory::NewStringFromAscii(source); 1353 Handle<String> source_code = Factory::NewStringFromAscii(source);
1327 bool result = CompileScriptCached(CStrVector(extension->name()), 1354 bool result = CompileScriptCached(CStrVector(extension->name()),
1328 source_code, 1355 source_code,
1329 &extensions_cache, extension, 1356 &extensions_cache,
1357 extension,
1358 Handle<Context>(Top::context()),
1330 false); 1359 false);
1331 ASSERT(Top::has_pending_exception() != result); 1360 ASSERT(Top::has_pending_exception() != result);
1332 if (!result) { 1361 if (!result) {
1333 Top::clear_pending_exception(); 1362 Top::clear_pending_exception();
1334 } 1363 }
1335 current->set_state(v8::INSTALLED); 1364 current->set_state(v8::INSTALLED);
1336 return result; 1365 return result;
1337 } 1366 }
1338 1367
1339 1368
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 previous_ = current_; 1592 previous_ = current_;
1564 current_ = this; 1593 current_ = this;
1565 result_ = Handle<Context>::null(); 1594 result_ = Handle<Context>::null();
1566 1595
1567 // If V8 isn't running and cannot be initialized, just return. 1596 // If V8 isn't running and cannot be initialized, just return.
1568 if (!V8::IsRunning() && !V8::Initialize(NULL)) return; 1597 if (!V8::IsRunning() && !V8::Initialize(NULL)) return;
1569 1598
1570 // Before creating the roots we must save the context and restore it 1599 // Before creating the roots we must save the context and restore it
1571 // on all function exits. 1600 // on all function exits.
1572 HandleScope scope; 1601 HandleScope scope;
1573 SaveContext context; 1602 SaveContext saved_context;
1574 1603
1575 CreateRoots(global_template, global_object); 1604 CreateRoots(global_template, global_object);
1576 1605
1577 if (!InstallNatives()) return; 1606 if (!InstallNatives()) return;
1578 1607
1579 MakeFunctionInstancePrototypeWritable(); 1608 MakeFunctionInstancePrototypeWritable();
1580 BuildSpecialFunctionTable(); 1609 BuildSpecialFunctionTable();
1581 1610
1582 if (!ConfigureGlobalObjects(global_template)) return; 1611 if (!ConfigureGlobalObjects(global_template)) return;
1583 1612
1584 if (!InstallExtensions(extensions)) return;
1585
1586 if (!InstallSpecialObjects()) return;
1587
1588 result_ = global_context_; 1613 result_ = global_context_;
1589 } 1614 }
1590 1615
1591 1616
1592 // Support for thread preemption. 1617 // Support for thread preemption.
1593 1618
1594 // Reserve space for statics needing saving and restoring. 1619 // Reserve space for statics needing saving and restoring.
1595 int Bootstrapper::ArchiveSpacePerThread() { 1620 int Bootstrapper::ArchiveSpacePerThread() {
1596 return Genesis::ArchiveSpacePerThread(); 1621 return Genesis::ArchiveSpacePerThread();
1597 } 1622 }
(...skipping 10 matching lines...) Expand all
1608 return Genesis::RestoreState(from); 1633 return Genesis::RestoreState(from);
1609 } 1634 }
1610 1635
1611 1636
1612 // Called when the top-level V8 mutex is destroyed. 1637 // Called when the top-level V8 mutex is destroyed.
1613 void Bootstrapper::FreeThreadResources() { 1638 void Bootstrapper::FreeThreadResources() {
1614 ASSERT(Genesis::current() == NULL); 1639 ASSERT(Genesis::current() == NULL);
1615 } 1640 }
1616 1641
1617 1642
1618 // Are there extensions that should be installed even if no extension was
1619 // specified?
1620 bool Bootstrapper::AutoExtensionsExist() {
1621 // Find auto extensions.
1622 v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
1623 while (current != NULL) {
1624 if (current->extension()->auto_enable()) return true;
1625 current = current->next();
1626 }
1627 return FLAG_expose_gc;
1628 }
1629
1630
1631 // Reserve space for statics needing saving and restoring. 1643 // Reserve space for statics needing saving and restoring.
1632 int Genesis::ArchiveSpacePerThread() { 1644 int Genesis::ArchiveSpacePerThread() {
1633 return sizeof(current_); 1645 return sizeof(current_);
1634 } 1646 }
1635 1647
1636 1648
1637 // Archive statics that are thread local. 1649 // Archive statics that are thread local.
1638 char* Genesis::ArchiveState(char* to) { 1650 char* Genesis::ArchiveState(char* to) {
1639 *reinterpret_cast<Genesis**>(to) = current_; 1651 *reinterpret_cast<Genesis**>(to) = current_;
1640 current_ = NULL; 1652 current_ = NULL;
1641 return to + sizeof(current_); 1653 return to + sizeof(current_);
1642 } 1654 }
1643 1655
1644 1656
1645 // Restore statics that are thread local. 1657 // Restore statics that are thread local.
1646 char* Genesis::RestoreState(char* from) { 1658 char* Genesis::RestoreState(char* from) {
1647 current_ = *reinterpret_cast<Genesis**>(from); 1659 current_ = *reinterpret_cast<Genesis**>(from);
1648 return from + sizeof(current_); 1660 return from + sizeof(current_);
1649 } 1661 }
1650 1662
1651 } } // namespace v8::internal 1663 } } // namespace v8::internal
OLDNEW
« src/bootstrapper.h ('K') | « src/bootstrapper.h ('k') | src/v8-counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698