Inline SetWrapperClassId() and WrapperClassId()

BUG=
TEST=test-api.cc (WrapperClassId)

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13405 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5da9e756
......@@ -3541,9 +3541,6 @@ class V8EXPORT V8 {
static bool IsGlobalWeak(internal::Object** global_handle);
static bool IsGlobalWeak(internal::Isolate* isolate,
internal::Object** global_handle);
static void SetWrapperClassId(internal::Object** global_handle,
uint16_t class_id);
static uint16_t GetWrapperClassId(internal::Object** global_handle);
template <class T> friend class Handle;
template <class T> friend class Local;
......@@ -4155,6 +4152,7 @@ class Internals {
static const int kIsolateStateOffset = 0;
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
static const int kIsolateRootsOffset = 3 * kApiPointerSize;
static const int kNodeClassIdOffset = 1 * kApiPointerSize;
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
static const int kUndefinedValueRootIndex = 5;
static const int kNullValueRootIndex = 7;
......@@ -4407,12 +4405,18 @@ void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
template <class T>
void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
V8::SetWrapperClassId(reinterpret_cast<internal::Object**>(**this), class_id);
typedef internal::Internals I;
internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
*reinterpret_cast<uint16_t*>(addr) = class_id;
}
template <class T>
uint16_t Persistent<T>::WrapperClassId() const {
return V8::GetWrapperClassId(reinterpret_cast<internal::Object**>(**this));
typedef internal::Internals I;
internal::Object** obj = reinterpret_cast<internal::Object**>(**this);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
return *reinterpret_cast<uint16_t*>(addr);
}
Arguments::Arguments(internal::Object** implicit_args,
......
......@@ -4807,16 +4807,6 @@ void Context::SetErrorMessageForCodeGenerationFromStrings(
}
void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) {
i::GlobalHandles::SetWrapperClassId(global_handle, class_id);
}
uint16_t V8::GetWrapperClassId(internal::Object** global_handle) {
return i::GlobalHandles::GetWrapperClassId(global_handle);
}
Local<v8::Object> ObjectTemplate::NewInstance() {
i::Isolate* isolate = i::Isolate::Current();
ON_BAILOUT(isolate, "v8::ObjectTemplate::NewInstance()",
......
......@@ -61,6 +61,7 @@ class GlobalHandles::Node {
Node() {
ASSERT(OFFSET_OF(Node, flags_) == Internals::kNodeFlagsOffset);
ASSERT(OFFSET_OF(Node, class_id_) == Internals::kNodeClassIdOffset);
ASSERT(static_cast<int>(IsIndependent::kShift) ==
Internals::kNodeIsIndependentShift);
ASSERT(static_cast<int>(IsPartiallyDependent::kShift) ==
......
......@@ -16687,6 +16687,18 @@ TEST(PersistentHandleVisitor) {
}
TEST(WrapperClassId) {
v8::HandleScope scope;
LocalContext context;
v8::Persistent<v8::Object> object =
v8::Persistent<v8::Object>::New(v8::Object::New());
CHECK_EQ(0, object.WrapperClassId());
object.SetWrapperClassId(65535);
CHECK_EQ(65535, object.WrapperClassId());
object.Dispose();
}
TEST(RegExp) {
v8::HandleScope scope;
LocalContext context;
......
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