Inline MarkIndependent(), MarkPartiallyDependent(), IsIndependent()

TEST=test-api.cc (IndependentWeakHandle, ApiObjectGroupsCycleForScavenger)

Review URL: https://codereview.chromium.org/11879044
Patch from Kentaro Hara <haraken@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13391 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ec9dc278
......@@ -4152,12 +4152,16 @@ class Internals {
static const int kIsolateStateOffset = 0;
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
static const int kIsolateRootsOffset = 3 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
static const int kUndefinedValueRootIndex = 5;
static const int kNullValueRootIndex = 7;
static const int kTrueValueRootIndex = 8;
static const int kFalseValueRootIndex = 9;
static const int kEmptySymbolRootIndex = 119;
static const int kNodeIsIndependentShift = 4;
static const int kNodeIsPartiallyDependentShift = 5;
static const int kJSObjectType = 0xab;
static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x82;
......@@ -4196,6 +4200,18 @@ class Internals {
return *reinterpret_cast<int*>(addr) == 1;
}
V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
return *addr & (1 << shift);
}
V8_INLINE(static void UpdateNodeFlag(internal::Object** obj,
bool value, int shift)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
uint8_t mask = 1 << shift;
*addr = (*addr & ~mask) | (value << shift);
}
V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
kIsolateEmbedderDataOffset;
......@@ -4289,9 +4305,11 @@ bool Persistent<T>::IsIndependent() const {
template <class T>
bool Persistent<T>::IsIndependent(Isolate* isolate) const {
typedef internal::Internals I;
if (this->IsEmpty()) return false;
return V8::IsGlobalIndependent(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(**this));
if (!I::IsInitialized(isolate)) return false;
return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this),
I::kNodeIsIndependentShift);
}
......@@ -4363,8 +4381,11 @@ void Persistent<T>::MarkIndependent() {
template <class T>
void Persistent<T>::MarkIndependent(Isolate* isolate) {
V8::MarkIndependent(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(**this));
typedef internal::Internals I;
if (this->IsEmpty()) return;
if (!I::IsInitialized(isolate)) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
true, I::kNodeIsIndependentShift);
}
template <class T>
......@@ -4374,8 +4395,11 @@ void Persistent<T>::MarkPartiallyDependent() {
template <class T>
void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
V8::MarkPartiallyDependent(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(**this));
typedef internal::Internals I;
if (this->IsEmpty()) return;
if (!I::IsInitialized(isolate)) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this),
true, I::kNodeIsPartiallyDependentShift);
}
template <class T>
......
......@@ -668,13 +668,6 @@ void V8::MarkIndependent(i::Object** object) {
}
void V8::MarkIndependent(i::Isolate* isolate, i::Object** object) {
ASSERT(isolate == i::Isolate::Current());
LOG_API(isolate, "MarkIndependent");
isolate->global_handles()->MarkIndependent(object);
}
void V8::MarkPartiallyDependent(i::Object** object) {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "MarkPartiallyDependent");
......@@ -682,13 +675,6 @@ void V8::MarkPartiallyDependent(i::Object** object) {
}
void V8::MarkPartiallyDependent(i::Isolate* isolate, i::Object** object) {
ASSERT(isolate == i::Isolate::Current());
LOG_API(isolate, "MarkPartiallyDependent");
isolate->global_handles()->MarkPartiallyDependent(object);
}
bool V8::IsGlobalIndependent(i::Object** obj) {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "IsGlobalIndependent");
......@@ -697,14 +683,6 @@ bool V8::IsGlobalIndependent(i::Object** obj) {
}
bool V8::IsGlobalIndependent(i::Isolate* isolate, i::Object** obj) {
ASSERT(isolate == i::Isolate::Current());
LOG_API(isolate, "IsGlobalIndependent");
if (!isolate->IsInitialized()) return false;
return i::GlobalHandles::IsIndependent(obj);
}
bool V8::IsGlobalNearDeath(i::Object** obj) {
i::Isolate* isolate = i::Isolate::Current();
LOG_API(isolate, "IsGlobalNearDeath");
......
......@@ -59,7 +59,13 @@ class GlobalHandles::Node {
return reinterpret_cast<Node*>(location);
}
Node() {}
Node() {
ASSERT(OFFSET_OF(Node, flags_) == Internals::kNodeFlagsOffset);
ASSERT(static_cast<int>(IsIndependent::kShift) ==
Internals::kNodeIsIndependentShift);
ASSERT(static_cast<int>(IsPartiallyDependent::kShift) ==
Internals::kNodeIsPartiallyDependentShift);
}
#ifdef DEBUG
~Node() {
......
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