Revert "Remove IsInitialized checks from inlined API functions."

This reverts r15277 due to failures in layout tests. Apparently Blink
still initializes the Isolate by calling v8::Null() as the first API
function on some paths.

TBR=svenpanne@chromium.org
TEST=webkit:crypto/worker-random-values-concurrent.html

Review URL: https://codereview.chromium.org/17577008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15281 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 00783736
...@@ -5301,6 +5301,7 @@ class Internals { ...@@ -5301,6 +5301,7 @@ class Internals {
static const int kExternalTwoByteRepresentationTag = 0x02; static const int kExternalTwoByteRepresentationTag = 0x02;
static const int kExternalAsciiRepresentationTag = 0x06; static const int kExternalAsciiRepresentationTag = 0x06;
static const int kIsolateStateOffset = 0;
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
static const int kIsolateRootsOffset = 3 * kApiPointerSize; static const int kIsolateRootsOffset = 3 * kApiPointerSize;
static const int kUndefinedValueRootIndex = 5; static const int kUndefinedValueRootIndex = 5;
...@@ -5325,12 +5326,6 @@ class Internals { ...@@ -5325,12 +5326,6 @@ class Internals {
static const int kUndefinedOddballKind = 5; static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3; static const int kNullOddballKind = 3;
#ifdef V8_ENABLE_CHECKS
static void CheckInitialized(v8::Isolate* isolate);
#else
static void CheckInitialized(v8::Isolate* isolate) { }
#endif
V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) {
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
kHeapObjectTag); kHeapObjectTag);
...@@ -5364,6 +5359,11 @@ class Internals { ...@@ -5364,6 +5359,11 @@ class Internals {
return representation == kExternalTwoByteRepresentationTag; return representation == kExternalTwoByteRepresentationTag;
} }
V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset;
return *reinterpret_cast<int*>(addr) == 1;
}
V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
return *addr & (1 << shift); return *addr & (1 << shift);
...@@ -5939,7 +5939,7 @@ String* String::Cast(v8::Value* value) { ...@@ -5939,7 +5939,7 @@ String* String::Cast(v8::Value* value) {
Local<String> String::Empty(Isolate* isolate) { Local<String> String::Empty(Isolate* isolate) {
typedef internal::Object* S; typedef internal::Object* S;
typedef internal::Internals I; typedef internal::Internals I;
I::CheckInitialized(isolate); if (!I::IsInitialized(isolate)) return Empty();
S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
return Local<String>(reinterpret_cast<String*>(slot)); return Local<String>(reinterpret_cast<String*>(slot));
} }
...@@ -6292,7 +6292,7 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { ...@@ -6292,7 +6292,7 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
Handle<Primitive> Undefined(Isolate* isolate) { Handle<Primitive> Undefined(Isolate* isolate) {
typedef internal::Object* S; typedef internal::Object* S;
typedef internal::Internals I; typedef internal::Internals I;
I::CheckInitialized(isolate); if (!I::IsInitialized(isolate)) return Undefined();
S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
} }
...@@ -6301,7 +6301,7 @@ Handle<Primitive> Undefined(Isolate* isolate) { ...@@ -6301,7 +6301,7 @@ Handle<Primitive> Undefined(Isolate* isolate) {
Handle<Primitive> Null(Isolate* isolate) { Handle<Primitive> Null(Isolate* isolate) {
typedef internal::Object* S; typedef internal::Object* S;
typedef internal::Internals I; typedef internal::Internals I;
I::CheckInitialized(isolate); if (!I::IsInitialized(isolate)) return Null();
S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
} }
...@@ -6310,7 +6310,7 @@ Handle<Primitive> Null(Isolate* isolate) { ...@@ -6310,7 +6310,7 @@ Handle<Primitive> Null(Isolate* isolate) {
Handle<Boolean> True(Isolate* isolate) { Handle<Boolean> True(Isolate* isolate) {
typedef internal::Object* S; typedef internal::Object* S;
typedef internal::Internals I; typedef internal::Internals I;
I::CheckInitialized(isolate); if (!I::IsInitialized(isolate)) return True();
S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
} }
...@@ -6319,7 +6319,7 @@ Handle<Boolean> True(Isolate* isolate) { ...@@ -6319,7 +6319,7 @@ Handle<Boolean> True(Isolate* isolate) {
Handle<Boolean> False(Isolate* isolate) { Handle<Boolean> False(Isolate* isolate) {
typedef internal::Object* S; typedef internal::Object* S;
typedef internal::Internals I; typedef internal::Internals I;
I::CheckInitialized(isolate); if (!I::IsInitialized(isolate)) return False();
S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); return Handle<Boolean>(reinterpret_cast<Boolean*>(slot));
} }
......
...@@ -2893,16 +2893,6 @@ Local<Integer> Value::ToInteger() const { ...@@ -2893,16 +2893,6 @@ Local<Integer> Value::ToInteger() const {
} }
#ifdef V8_ENABLE_CHECKS
void i::Internals::CheckInitialized(v8::Isolate* external_isolate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
ApiCheck(isolate != NULL && isolate->IsInitialized() && !i::V8::IsDead(),
"v8::internal::Internals::CheckInitialized()",
"Isolate is not initialized or V8 has died");
}
#endif
void External::CheckCast(v8::Value* that) { void External::CheckCast(v8::Value* that) {
if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return; if (IsDeadCheck(i::Isolate::Current(), "v8::External::Cast()")) return;
ApiCheck(Utils::OpenHandle(that)->IsExternal(), ApiCheck(Utils::OpenHandle(that)->IsExternal(),
......
...@@ -2216,6 +2216,8 @@ bool Isolate::Init(Deserializer* des) { ...@@ -2216,6 +2216,8 @@ bool Isolate::Init(Deserializer* des) {
LOG(this, LogCompiledFunctions()); LOG(this, LogCompiledFunctions());
} }
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, state_)),
Internals::kIsolateStateOffset);
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)),
Internals::kIsolateEmbedderDataOffset); Internals::kIsolateEmbedderDataOffset);
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)),
......
...@@ -18796,6 +18796,13 @@ TEST(PrimaryStubCache) { ...@@ -18796,6 +18796,13 @@ TEST(PrimaryStubCache) {
} }
static int fatal_error_callback_counter = 0;
static void CountingErrorCallback(const char* location, const char* message) {
printf("CountingErrorCallback(\"%s\", \"%s\")\n", location, message);
fatal_error_callback_counter++;
}
TEST(StaticGetters) { TEST(StaticGetters) {
LocalContext context; LocalContext context;
i::Factory* factory = i::Isolate::Current()->factory(); i::Factory* factory = i::Isolate::Current()->factory();
...@@ -18813,6 +18820,31 @@ TEST(StaticGetters) { ...@@ -18813,6 +18820,31 @@ TEST(StaticGetters) {
i::Handle<i::Object> false_value = factory->false_value(); i::Handle<i::Object> false_value = factory->false_value();
CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
// Test after-death behavior.
CHECK(i::Internals::IsInitialized(isolate));
CHECK_EQ(0, fatal_error_callback_counter);
v8::V8::SetFatalErrorHandler(CountingErrorCallback);
v8::Utils::ReportApiFailure("StaticGetters()", "Kill V8");
i::Isolate::Current()->TearDown();
CHECK(!i::Internals::IsInitialized(isolate));
CHECK_EQ(1, fatal_error_callback_counter);
CHECK(v8::Undefined().IsEmpty());
CHECK_EQ(2, fatal_error_callback_counter);
CHECK(v8::Undefined(isolate).IsEmpty());
CHECK_EQ(3, fatal_error_callback_counter);
CHECK(v8::Null().IsEmpty());
CHECK_EQ(4, fatal_error_callback_counter);
CHECK(v8::Null(isolate).IsEmpty());
CHECK_EQ(5, fatal_error_callback_counter);
CHECK(v8::True().IsEmpty());
CHECK_EQ(6, fatal_error_callback_counter);
CHECK(v8::True(isolate).IsEmpty());
CHECK_EQ(7, fatal_error_callback_counter);
CHECK(v8::False().IsEmpty());
CHECK_EQ(8, fatal_error_callback_counter);
CHECK(v8::False(isolate).IsEmpty());
CHECK_EQ(9, fatal_error_callback_counter);
} }
...@@ -18842,6 +18874,19 @@ TEST(StringEmpty) { ...@@ -18842,6 +18874,19 @@ TEST(StringEmpty) {
i::Handle<i::Object> empty_string = factory->empty_string(); i::Handle<i::Object> empty_string = factory->empty_string();
CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string);
// Test after-death behavior.
CHECK(i::Internals::IsInitialized(isolate));
CHECK_EQ(0, fatal_error_callback_counter);
v8::V8::SetFatalErrorHandler(CountingErrorCallback);
v8::Utils::ReportApiFailure("StringEmpty()", "Kill V8");
i::Isolate::Current()->TearDown();
CHECK(!i::Internals::IsInitialized(isolate));
CHECK_EQ(1, fatal_error_callback_counter);
CHECK(v8::String::Empty().IsEmpty());
CHECK_EQ(2, fatal_error_callback_counter);
CHECK(v8::String::Empty(isolate).IsEmpty());
CHECK_EQ(3, fatal_error_callback_counter);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment