| OLD | NEW |
| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 Genesis(Handle<Object> global_object, | 258 Genesis(Handle<Object> global_object, |
| 259 v8::Handle<v8::ObjectTemplate> global_template, | 259 v8::Handle<v8::ObjectTemplate> global_template, |
| 260 v8::ExtensionConfiguration* extensions); | 260 v8::ExtensionConfiguration* extensions); |
| 261 ~Genesis(); | 261 ~Genesis(); |
| 262 | 262 |
| 263 Handle<Context> result() { return result_; } | 263 Handle<Context> result() { return result_; } |
| 264 | 264 |
| 265 Genesis* previous() { return previous_; } | 265 Genesis* previous() { return previous_; } |
| 266 static Genesis* current() { return current_; } | 266 static Genesis* current() { return current_; } |
| 267 | 267 |
| 268 // Support for thread preemption. |
| 269 static int ArchiveSpacePerThread(); |
| 270 static char* ArchiveState(char* to); |
| 271 static char* RestoreState(char* from); |
| 272 |
| 268 private: | 273 private: |
| 269 Handle<Context> global_context_; | 274 Handle<Context> global_context_; |
| 270 | 275 |
| 271 // There may be more than one active genesis object: When GC is | 276 // There may be more than one active genesis object: When GC is |
| 272 // triggered during environment creation there may be weak handle | 277 // triggered during environment creation there may be weak handle |
| 273 // processing callbacks which may create new environments. | 278 // processing callbacks which may create new environments. |
| 274 Genesis* previous_; | 279 Genesis* previous_; |
| 275 static Genesis* current_; | 280 static Genesis* current_; |
| 276 | 281 |
| 277 Handle<Context> global_context() { return global_context_; } | 282 Handle<Context> global_context() { return global_context_; } |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 Factory::NewJSObject(Top::object_function(), TENURED), | 1081 Factory::NewJSObject(Top::object_function(), TENURED), |
| 1077 Builtins::FunctionApply, | 1082 Builtins::FunctionApply, |
| 1078 false); | 1083 false); |
| 1079 | 1084 |
| 1080 // Make sure that Function.prototype.call appears to be compiled. | 1085 // Make sure that Function.prototype.call appears to be compiled. |
| 1081 // The code will never be called, but inline caching for call will | 1086 // The code will never be called, but inline caching for call will |
| 1082 // only work if it appears to be compiled. | 1087 // only work if it appears to be compiled. |
| 1083 call->shared()->DontAdaptArguments(); | 1088 call->shared()->DontAdaptArguments(); |
| 1084 ASSERT(call->is_compiled()); | 1089 ASSERT(call->is_compiled()); |
| 1085 | 1090 |
| 1086 // Set the expected paramters for apply to 2; required by builtin. | 1091 // Set the expected parameters for apply to 2; required by builtin. |
| 1087 apply->shared()->set_formal_parameter_count(2); | 1092 apply->shared()->set_formal_parameter_count(2); |
| 1088 | 1093 |
| 1089 // Set the lengths for the functions to satisfy ECMA-262. | 1094 // Set the lengths for the functions to satisfy ECMA-262. |
| 1090 call->shared()->set_length(1); | 1095 call->shared()->set_length(1); |
| 1091 apply->shared()->set_length(2); | 1096 apply->shared()->set_length(2); |
| 1092 } | 1097 } |
| 1093 | 1098 |
| 1094 // Make sure that the builtins object has fast properties. | 1099 // Make sure that the builtins object has fast properties. |
| 1095 // If the ASSERT below fails, please increase the expected number of | 1100 // If the ASSERT below fails, please increase the expected number of |
| 1096 // properties for the builtins object. | 1101 // properties for the builtins object. |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); | 1435 Handle<Code>(Builtins::builtin(Builtins::ArrayPop))); |
| 1431 AddSpecialFunction(prototype, "push", | 1436 AddSpecialFunction(prototype, "push", |
| 1432 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); | 1437 Handle<Code>(Builtins::builtin(Builtins::ArrayPush))); |
| 1433 } | 1438 } |
| 1434 | 1439 |
| 1435 | 1440 |
| 1436 Genesis::Genesis(Handle<Object> global_object, | 1441 Genesis::Genesis(Handle<Object> global_object, |
| 1437 v8::Handle<v8::ObjectTemplate> global_template, | 1442 v8::Handle<v8::ObjectTemplate> global_template, |
| 1438 v8::ExtensionConfiguration* extensions) { | 1443 v8::ExtensionConfiguration* extensions) { |
| 1439 // Link this genesis object into the stacked genesis chain. This | 1444 // Link this genesis object into the stacked genesis chain. This |
| 1440 // must be done before any early exits because the deconstructor | 1445 // must be done before any early exits because the destructor |
| 1441 // will always do unlinking. | 1446 // will always do unlinking. |
| 1442 previous_ = current_; | 1447 previous_ = current_; |
| 1443 current_ = this; | 1448 current_ = this; |
| 1444 result_ = NULL; | 1449 result_ = NULL; |
| 1445 | 1450 |
| 1446 // If V8 hasn't been and cannot be initialized, just return. | 1451 // If V8 hasn't been and cannot be initialized, just return. |
| 1447 if (!V8::HasBeenSetup() && !V8::Initialize(NULL)) return; | 1452 if (!V8::HasBeenSetup() && !V8::Initialize(NULL)) return; |
| 1448 | 1453 |
| 1449 // Before creating the roots we must save the context and restore it | 1454 // Before creating the roots we must save the context and restore it |
| 1450 // on all function exits. | 1455 // on all function exits. |
| 1451 HandleScope scope; | 1456 HandleScope scope; |
| 1452 SaveContext context; | 1457 SaveContext context; |
| 1453 | 1458 |
| 1454 CreateRoots(global_template, global_object); | 1459 CreateRoots(global_template, global_object); |
| 1455 if (!InstallNatives()) return; | 1460 if (!InstallNatives()) return; |
| 1456 | 1461 |
| 1457 MakeFunctionInstancePrototypeWritable(); | 1462 MakeFunctionInstancePrototypeWritable(); |
| 1458 BuildSpecialFunctionTable(); | 1463 BuildSpecialFunctionTable(); |
| 1459 | 1464 |
| 1460 if (!ConfigureGlobalObjects(global_template)) return; | 1465 if (!ConfigureGlobalObjects(global_template)) return; |
| 1461 | 1466 |
| 1462 if (!InstallExtensions(extensions)) return; | 1467 if (!InstallExtensions(extensions)) return; |
| 1463 | 1468 |
| 1464 if (!InstallSpecialObjects()) return; | 1469 if (!InstallSpecialObjects()) return; |
| 1465 | 1470 |
| 1466 result_ = global_context_; | 1471 result_ = global_context_; |
| 1467 } | 1472 } |
| 1468 | 1473 |
| 1474 |
| 1475 // Support for thread preemption. |
| 1476 |
| 1477 // Reserve space for statics needing saving and restoring. |
| 1478 int Bootstrapper::ArchiveSpacePerThread() { |
| 1479 return Genesis::ArchiveSpacePerThread(); |
| 1480 } |
| 1481 |
| 1482 |
| 1483 // Archive statics that are thread local. |
| 1484 char* Bootstrapper::ArchiveState(char* to) { |
| 1485 return Genesis::ArchiveState(to); |
| 1486 } |
| 1487 |
| 1488 |
| 1489 // Restore statics that are thread local. |
| 1490 char* Bootstrapper::RestoreState(char* from) { |
| 1491 return Genesis::RestoreState(from); |
| 1492 } |
| 1493 |
| 1494 |
| 1495 // Reserve space for statics needing saving and restoring. |
| 1496 int Genesis::ArchiveSpacePerThread() { |
| 1497 return sizeof(current_); |
| 1498 } |
| 1499 |
| 1500 |
| 1501 // Archive statics that are thread local. |
| 1502 char* Genesis::ArchiveState(char* to) { |
| 1503 *reinterpret_cast<Genesis**>(to) = current_; |
| 1504 current_ = NULL; |
| 1505 return to + sizeof(current_); |
| 1506 } |
| 1507 |
| 1508 |
| 1509 // Restore statics that are thread local. |
| 1510 char* Genesis::RestoreState(char* from) { |
| 1511 current_ = *reinterpret_cast<Genesis**>(from); |
| 1512 return from + sizeof(current_); |
| 1513 } |
| 1514 |
| 1469 } } // namespace v8::internal | 1515 } } // namespace v8::internal |
| OLD | NEW |