Revision: 4931
Author: [email protected]
Date: Wed Jun 23 09:21:33 2010
Log: [Isolates] Make statics from BootstrapperActive to be instance members
of Bootstrapper. Bootstrapper::IsActive is also instance method now.
Landing patch by Maxim.Mossienko with minor style changes.
Original review: http://codereview.chromium.org/2813026/show
Review URL: http://codereview.chromium.org/2861017
http://code.google.com/p/v8/source/detail?r=4931
Modified:
/branches/experimental/isolates/src/arm/codegen-arm.cc
/branches/experimental/isolates/src/bootstrapper.cc
/branches/experimental/isolates/src/bootstrapper.h
/branches/experimental/isolates/src/codegen.cc
/branches/experimental/isolates/src/compiler.cc
/branches/experimental/isolates/src/contexts.cc
/branches/experimental/isolates/src/execution.cc
/branches/experimental/isolates/src/heap.cc
/branches/experimental/isolates/src/ia32/codegen-ia32.cc
/branches/experimental/isolates/src/mips/codegen-mips.cc
/branches/experimental/isolates/src/objects.cc
/branches/experimental/isolates/src/parser.cc
/branches/experimental/isolates/src/top.cc
/branches/experimental/isolates/src/x64/codegen-x64.cc
=======================================
--- /branches/experimental/isolates/src/arm/codegen-arm.cc Mon Jun 21
10:40:11 2010
+++ /branches/experimental/isolates/src/arm/codegen-arm.cc Wed Jun 23
09:21:33 2010
@@ -330,7 +330,7 @@
if (!scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ function body");
#ifdef DEBUG
- bool is_builtin = Bootstrapper::IsActive();
+ bool is_builtin = Isolate::Current()->bootstrapper()->IsActive();
bool should_trace =
is_builtin ? FLAG_trace_builtin_calls : FLAG_trace_calls;
if (should_trace) {
=======================================
--- /branches/experimental/isolates/src/bootstrapper.cc Mon Jun 21 10:40:11
2010
+++ /branches/experimental/isolates/src/bootstrapper.cc Wed Jun 23 09:21:33
2010
@@ -111,7 +111,8 @@
}
-Bootstrapper::Bootstrapper() {
+Bootstrapper::Bootstrapper()
+ : nesting_(0) {
}
@@ -1396,9 +1397,6 @@
global_context()->set_jsfunction_result_caches(*caches);
}
-
-
-int BootstrapperActive::nesting_ = 0;
bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
@@ -1781,46 +1779,28 @@
// Reserve space for statics needing saving and restoring.
int Bootstrapper::ArchiveSpacePerThread() {
- return BootstrapperActive::ArchiveSpacePerThread();
+ return sizeof(NestingCounterType);
}
// Archive statics that are thread local.
char* Bootstrapper::ArchiveState(char* to) {
- return BootstrapperActive::ArchiveState(to);
+ *reinterpret_cast<NestingCounterType*>(to) = nesting_;
+ nesting_ = 0;
+ return to + sizeof(NestingCounterType);
}
// Restore statics that are thread local.
char* Bootstrapper::RestoreState(char* from) {
- return BootstrapperActive::RestoreState(from);
+ nesting_ = *reinterpret_cast<NestingCounterType*>(from);
+ return from + sizeof(NestingCounterType);
}
// Called when the top-level V8 mutex is destroyed.
void Bootstrapper::FreeThreadResources() {
- ASSERT(!BootstrapperActive::IsActive());
-}
-
-
-// Reserve space for statics needing saving and restoring.
-int BootstrapperActive::ArchiveSpacePerThread() {
- return sizeof(nesting_);
-}
-
-
-// Archive statics that are thread local.
-char* BootstrapperActive::ArchiveState(char* to) {
- *reinterpret_cast<int*>(to) = nesting_;
- nesting_ = 0;
- return to + sizeof(nesting_);
-}
-
-
-// Restore statics that are thread local.
-char* BootstrapperActive::RestoreState(char* from) {
- nesting_ = *reinterpret_cast<int*>(from);
- return from + sizeof(nesting_);
+ ASSERT(!IsActive());
}
} } // namespace v8::internal
=======================================
--- /branches/experimental/isolates/src/bootstrapper.h Tue Jun 8 13:45:42
2010
+++ /branches/experimental/isolates/src/bootstrapper.h Wed Jun 23 09:21:33
2010
@@ -33,23 +33,6 @@
namespace internal {
-class BootstrapperActive BASE_EMBEDDED {
- public:
- BootstrapperActive() { nesting_++; }
- ~BootstrapperActive() { nesting_--; }
-
- // Support for thread preemption.
- static int ArchiveSpacePerThread();
- static char* ArchiveState(char* to);
- static char* RestoreState(char* from);
-
- private:
- static bool IsActive() { return nesting_ != 0; }
- static int nesting_;
- friend class Bootstrapper;
-};
-
-
// The Boostrapper is the public interface for creating a JavaScript global
// context.
class Bootstrapper {
@@ -78,7 +61,7 @@
static Handle<String> NativesSourceLookup(int index);
// Tells whether bootstrapping is active.
- static bool IsActive() { return BootstrapperActive::IsActive(); }
+ bool IsActive() const { return nesting_ != 0; }
// Support for thread preemption.
RLYSTC int ArchiveSpacePerThread();
@@ -95,13 +78,33 @@
v8::ExtensionConfiguration* extensions);
private:
+ typedef int NestingCounterType;
+ NestingCounterType nesting_;
+
+ friend class BootstrapperActive;
friend class Isolate;
+
Bootstrapper();
DISALLOW_COPY_AND_ASSIGN(Bootstrapper);
};
+class BootstrapperActive BASE_EMBEDDED {
+ public:
+ BootstrapperActive() {
+ ++Isolate::Current()->bootstrapper()->nesting_;
+ }
+
+ ~BootstrapperActive() {
+ --Isolate::Current()->bootstrapper()->nesting_;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BootstrapperActive);
+};
+
+
class NativesExternalStringResource
: public v8::String::ExternalAsciiStringResource {
public:
=======================================
--- /branches/experimental/isolates/src/codegen.cc Mon Jun 21 10:40:11 2010
+++ /branches/experimental/isolates/src/codegen.cc Wed Jun 23 09:21:33 2010
@@ -120,7 +120,7 @@
bool print_json_ast = false;
const char* ftype;
- if (Bootstrapper::IsActive()) {
+ if (Isolate::Current()->bootstrapper()->IsActive()) {
print_source = FLAG_print_builtin_source;
print_ast = FLAG_print_builtin_ast;
print_json_ast = FLAG_print_builtin_json_ast;
@@ -167,7 +167,7 @@
Factory::NewCode(desc, &sinfo, flags, masm->CodeObject());
#ifdef ENABLE_DISASSEMBLER
- bool print_code = Bootstrapper::IsActive()
+ bool print_code = Isolate::Current()->bootstrapper()->IsActive()
? FLAG_print_builtin_code
: FLAG_print_code;
if (print_code) {
=======================================
--- /branches/experimental/isolates/src/compiler.cc Mon Jun 21 10:40:11 2010
+++ /branches/experimental/isolates/src/compiler.cc Wed Jun 23 09:21:33 2010
@@ -78,7 +78,7 @@
}
#ifdef DEBUG
- if (Bootstrapper::IsActive() ?
+ if (Isolate::Current()->bootstrapper()->IsActive() ?
FLAG_print_builtin_scopes :
FLAG_print_scopes) {
info->scope()->Print();
=======================================
--- /branches/experimental/isolates/src/contexts.cc Tue Jun 1 03:51:42 2010
+++ /branches/experimental/isolates/src/contexts.cc Wed Jun 23 09:21:33 2010
@@ -55,7 +55,7 @@
// During bootstrapping, the global object might not be set and we
// have to search the context chain to find the global context.
- ASSERT(Bootstrapper::IsActive());
+ ASSERT(Isolate::Current()->bootstrapper()->IsActive());
Context* current = this;
while (!current->IsGlobalContext()) {
JSFunction* closure = JSFunction::cast(current->closure());
@@ -242,14 +242,15 @@
bool Context::IsBootstrappingOrContext(Object* object) {
// During bootstrapping we allow all objects to pass as
// contexts. This is necessary to fix circular dependencies.
- return Bootstrapper::IsActive() || object->IsContext();
+ return Isolate::Current()->bootstrapper()->IsActive() ||
object->IsContext();
}
bool Context::IsBootstrappingOrGlobalObject(Object* object) {
// During bootstrapping we allow all objects to pass as global
// objects. This is necessary to fix circular dependencies.
- return Bootstrapper::IsActive() || object->IsGlobalObject();
+ return Isolate::Current()->bootstrapper()->IsActive() ||
+ object->IsGlobalObject();
}
#endif
=======================================
--- /branches/experimental/isolates/src/execution.cc Mon Jun 21 10:40:11
2010
+++ /branches/experimental/isolates/src/execution.cc Wed Jun 23 09:21:33
2010
@@ -643,7 +643,7 @@
}
// Ignore debug break during bootstrapping.
- if (Bootstrapper::IsActive()) {
+ if (isolate->bootstrapper()->IsActive()) {
return isolate->heap()->undefined_value();
}
=======================================
--- /branches/experimental/isolates/src/heap.cc Mon Jun 21 15:48:21 2010
+++ /branches/experimental/isolates/src/heap.cc Wed Jun 23 09:21:33 2010
@@ -546,7 +546,7 @@
void Heap::ClearJSFunctionResultCaches() {
- if (Bootstrapper::IsActive()) return;
+ if (isolate_->bootstrapper()->IsActive()) return;
ClearThreadJSFunctionResultCachesVisitor visitor;
ThreadManager::IterateArchivedThreads(&visitor);
}
@@ -4691,7 +4691,7 @@
#ifdef DEBUG
bool Heap::GarbageCollectionGreedyCheck() {
ASSERT(FLAG_gc_greedy);
- if (Bootstrapper::IsActive()) return true;
+ if (isolate_->bootstrapper()->IsActive()) return true;
if (disallow_allocation_failure()) return true;
return CollectGarbage(0, NEW_SPACE);
}
=======================================
--- /branches/experimental/isolates/src/ia32/codegen-ia32.cc Mon Jun 21
10:40:11 2010
+++ /branches/experimental/isolates/src/ia32/codegen-ia32.cc Wed Jun 23
09:21:33 2010
@@ -336,7 +336,7 @@
if (!scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ function body");
#ifdef DEBUG
- bool is_builtin = Bootstrapper::IsActive();
+ bool is_builtin = Isolate::Current()->bootstrapper()->IsActive();
bool should_trace =
is_builtin ? FLAG_trace_builtin_calls : FLAG_trace_calls;
if (should_trace) {
=======================================
--- /branches/experimental/isolates/src/mips/codegen-mips.cc Mon Jun 21
10:40:11 2010
+++ /branches/experimental/isolates/src/mips/codegen-mips.cc Wed Jun 23
09:21:33 2010
@@ -201,7 +201,7 @@
if (!scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ function body");
#ifdef DEBUG
- bool is_builtin = Bootstrapper::IsActive();
+ bool is_builtin = Isolate::Current()->bootstrapper()->IsActive();
bool should_trace =
is_builtin ? FLAG_trace_builtin_calls : FLAG_trace_calls;
if (should_trace) {
=======================================
--- /branches/experimental/isolates/src/objects.cc Mon Jun 21 10:40:11 2010
+++ /branches/experimental/isolates/src/objects.cc Wed Jun 23 09:21:33 2010
@@ -2655,15 +2655,18 @@
if (!IsJSGlobalProxy() && IsAccessCheckNeeded()) {
result->DisallowCaching();
}
+
+ Isolate* isolate = Isolate::Current();
// Check __proto__ before interceptor.
- if (name->Equals(HEAP->Proto_symbol()) && !IsJSContextExtensionObject())
{
+ if (name->Equals(isolate->heap()->Proto_symbol()) &&
+ !IsJSContextExtensionObject()) {
result->ConstantResult(this);
return;
}
// Check for lookup interceptor except when bootstrapping.
- if (HasNamedInterceptor() && !Bootstrapper::IsActive()) {
+ if (HasNamedInterceptor() && !isolate->bootstrapper()->IsActive()) {
result->InterceptorResult(this);
return;
}
=======================================
--- /branches/experimental/isolates/src/parser.cc Mon Jun 21 10:40:11 2010
+++ /branches/experimental/isolates/src/parser.cc Wed Jun 23 09:21:33 2010
@@ -5097,7 +5097,7 @@
bool allow_natives_syntax =
always_allow_natives_syntax ||
FLAG_allow_natives_syntax ||
- Bootstrapper::IsActive();
+ Isolate::Current()->bootstrapper()->IsActive();
PreParser parser(no_script, allow_natives_syntax, extension);
if (!parser.PreParseProgram(source, stream)) return NULL;
// The list owns the backing store so we need to clone the vector.
@@ -5138,7 +5138,7 @@
bool allow_natives_syntax =
always_allow_natives_syntax ||
FLAG_allow_natives_syntax ||
- Bootstrapper::IsActive();
+ Isolate::Current()->bootstrapper()->IsActive();
AstBuildingParser parser(script, allow_natives_syntax, extension,
pre_data);
if (pre_data != NULL && pre_data->has_error()) {
Scanner::Location loc = pre_data->MessageLocation();
=======================================
--- /branches/experimental/isolates/src/top.cc Mon Jun 21 10:40:11 2010
+++ /branches/experimental/isolates/src/top.cc Wed Jun 23 09:21:33 2010
@@ -389,7 +389,7 @@
JSObject* receiver,
v8::AccessType type) {
// During bootstrapping, callback functions are not enabled yet.
- if (Bootstrapper::IsActive()) return YES;
+ if (isolate->bootstrapper()->IsActive()) return YES;
if (receiver->IsJSGlobalProxy()) {
Object* receiver_context = JSGlobalProxy::cast(receiver)->context();
@@ -617,7 +617,7 @@
MessageLocation* location,
Handle<String> stack_trace) {
Handle<Object> message;
- if (!Bootstrapper::IsActive()) {
+ if (!bootstrapper()->IsActive()) {
// It's not safe to try to make message objects while the bootstrapper
// is active since the infrastructure may not have been properly
// initialized.
@@ -699,7 +699,7 @@
ComputeLocation(&potential_computed_location);
location = &potential_computed_location;
}
- if (!Bootstrapper::IsActive()) {
+ if (!bootstrapper()->IsActive()) {
// It's not safe to try to make message objects or collect stack
// traces while the bootstrapper is active since the infrastructure
// may not have been properly initialized.
=======================================
--- /branches/experimental/isolates/src/x64/codegen-x64.cc Mon Jun 21
10:40:11 2010
+++ /branches/experimental/isolates/src/x64/codegen-x64.cc Wed Jun 23
09:21:33 2010
@@ -523,7 +523,7 @@
if (!scope()->HasIllegalRedeclaration()) {
Comment cmnt(masm_, "[ function body");
#ifdef DEBUG
- bool is_builtin = Bootstrapper::IsActive();
+ bool is_builtin = Isolate::Current()->bootstrapper()->IsActive();
bool should_trace =
is_builtin ? FLAG_trace_builtin_calls : FLAG_trace_calls;
if (should_trace) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev