remove most uses of raw handle constructors

R=svenpanne@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15107 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
dcarney@chromium.org 2013-06-13 09:27:09 +00:00
parent 28db1d0ebd
commit 8b2c26d736
22 changed files with 262 additions and 253 deletions

View File

@ -123,7 +123,6 @@ class ImplementationUtilities;
class Int32;
class Integer;
class Isolate;
class LocalContext;
class Number;
class NumberObject;
class Object;
@ -162,8 +161,7 @@ class Heap;
class HeapObject;
class Isolate;
class Object;
template<typename T>
class CustomArguments;
template<typename T> class CustomArguments;
class PropertyCallbackArguments;
class FunctionCallbackArguments;
}
@ -365,21 +363,19 @@ template <class T> class Handle {
#endif
private:
friend class Utils;
template<class F> friend class Persistent;
template<class F> friend class Local;
friend class Arguments;
template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo;
friend class String;
friend class Object;
template<class F> friend class CustomArguments;
friend class AccessorInfo;
friend Handle<Primitive> Undefined(Isolate* isolate);
friend Handle<Primitive> Null(Isolate* isolate);
friend Handle<Boolean> True(Isolate* isolate);
friend Handle<Boolean> False(Isolate* isolate);
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
friend class HandleScope;
#ifndef V8_USE_UNSAFE_HANDLES
@ -454,6 +450,7 @@ template <class T> class Local : public Handle<T> {
#endif
private:
friend class Utils;
template<class F> friend class Persistent;
template<class F> friend class Handle;
friend class Arguments;
@ -463,8 +460,7 @@ template <class T> class Local : public Handle<T> {
friend class Object;
friend class AccessorInfo;
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
template<class F> friend class CustomArguments;
friend class HandleScope;
V8_INLINE(static Local<T> New(Isolate* isolate, T* that));
@ -511,11 +507,11 @@ template <class T> class Persistent // NOLINT
* to be separately disposed.
*/
template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that))
: val_(*New(isolate, that)) { }
: val_(New(isolate, *that)) { }
template <class S> V8_INLINE(Persistent(Isolate* isolate,
Persistent<S>& that)) // NOLINT
: val_(*New(isolate, that)) { }
: val_(New(isolate, *that)) { }
#else
/**
@ -594,15 +590,9 @@ template <class T> class Persistent // NOLINT
}
#endif
#ifdef V8_USE_UNSAFE_HANDLES
V8_DEPRECATED(static Persistent<T> New(Handle<T> that));
/**
* Creates a new persistent handle for an existing local or persistent handle.
*/
// TODO(dcarney): remove before cutover
V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that));
#ifndef V8_USE_UNSAFE_HANDLES
// TODO(dcarney): remove before cutover
V8_INLINE(static Persistent<T> New(Isolate* isolate, Persistent<T> that));
#endif
@ -773,11 +763,7 @@ template <class T> class Persistent // NOLINT
#endif
// TODO(dcarney): remove before cutover
template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { }
// TODO(dcarney): remove before cutover
template <class S> V8_INLINE(Persistent(Persistent<S> that))
: val_(*that) {
TYPE_CHECK(T, S);
}
// TODO(dcarney): remove before cutover
V8_INLINE(T* operator*() const) { return val_; }
@ -788,16 +774,13 @@ template <class T> class Persistent // NOLINT
#endif
private:
friend class Utils;
template<class F> friend class Handle;
template<class F> friend class Local;
template<class F> friend class Persistent;
template<class F> friend class ReturnValue;
friend class ImplementationUtilities;
friend class ObjectTemplate;
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
V8_INLINE(static Persistent<T> New(Isolate* isolate, T* that));
V8_INLINE(static T* New(Isolate* isolate, T* that));
#ifndef V8_USE_UNSAFE_HANDLES
T* val_;
@ -5504,6 +5487,7 @@ Local<T> Local<T>::New(Isolate* isolate, T* that) {
}
#ifdef V8_USE_UNSAFE_HANDLES
template <class T>
Persistent<T> Persistent<T>::New(Handle<T> that) {
return New(Isolate::GetCurrent(), that.val_);
@ -5515,20 +5499,20 @@ Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) {
return New(Isolate::GetCurrent(), that.val_);
}
#ifndef V8_USE_UNSAFE_HANDLES
template <class T>
Persistent<T> Persistent<T>::New(Isolate* isolate, Persistent<T> that) {
return New(Isolate::GetCurrent(), that.val_);
}
#endif
template <class T>
Persistent<T> Persistent<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return Persistent<T>();
T* Persistent<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return NULL;
internal::Object** p = reinterpret_cast<internal::Object**>(that);
return Persistent<T>(reinterpret_cast<T*>(
return reinterpret_cast<T*>(
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
p)));
p));
}

View File

@ -552,8 +552,7 @@ v8::Handle<Primitive> Undefined() {
if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
return v8::Handle<v8::Primitive>();
}
return v8::Handle<Primitive>(ToApi<Primitive>(
isolate->factory()->undefined_value()));
return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
}
@ -562,8 +561,7 @@ v8::Handle<Primitive> Null() {
if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) {
return v8::Handle<v8::Primitive>();
}
return v8::Handle<Primitive>(
ToApi<Primitive>(isolate->factory()->null_value()));
return ToApiHandle<Primitive>(isolate->factory()->null_value());
}
@ -572,8 +570,7 @@ v8::Handle<Boolean> True() {
if (!EnsureInitializedForIsolate(isolate, "v8::True()")) {
return v8::Handle<Boolean>();
}
return v8::Handle<Boolean>(
ToApi<Boolean>(isolate->factory()->true_value()));
return ToApiHandle<Boolean>(isolate->factory()->true_value());
}
@ -582,8 +579,7 @@ v8::Handle<Boolean> False() {
if (!EnsureInitializedForIsolate(isolate, "v8::False()")) {
return v8::Handle<Boolean>();
}
return v8::Handle<Boolean>(
ToApi<Boolean>(isolate->factory()->false_value()));
return ToApiHandle<Boolean>(isolate->factory()->false_value());
}
@ -953,7 +949,7 @@ Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
result = Utils::OpenHandle(*ObjectTemplate::New());
Utils::OpenHandle(this)->set_prototype_template(*result);
}
return Local<ObjectTemplate>(ToApi<ObjectTemplate>(result));
return ToApiHandle<ObjectTemplate>(result);
}
@ -1048,8 +1044,7 @@ template<typename Operation>
static Local<Operation> NewDescriptor(
Isolate* isolate,
const i::DeclaredAccessorDescriptorData& data,
Data* previous_descriptor
) {
Data* previous_descriptor) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::DeclaredAccessorDescriptor> previous =
i::Handle<i::DeclaredAccessorDescriptor>();
@ -1059,8 +1054,7 @@ static Local<Operation> NewDescriptor(
}
i::Handle<i::DeclaredAccessorDescriptor> descriptor =
i::DeclaredAccessorDescriptor::Create(internal_isolate, data, previous);
return Local<Operation>(
reinterpret_cast<Operation*>(*Utils::ToLocal(descriptor)));
return Utils::Convert<i::DeclaredAccessorDescriptor, Operation>(descriptor);
}
@ -1301,13 +1295,14 @@ Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() {
|| EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this))
return Local<ObjectTemplate>();
ENTER_V8(isolate);
if (Utils::OpenHandle(this)->instance_template()->IsUndefined()) {
i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this);
if (handle->instance_template()->IsUndefined()) {
Local<ObjectTemplate> templ =
ObjectTemplate::New(v8::Handle<FunctionTemplate>(this));
Utils::OpenHandle(this)->set_instance_template(*Utils::OpenHandle(*templ));
ObjectTemplate::New(ToApiHandle<FunctionTemplate>(handle));
handle->set_instance_template(*Utils::OpenHandle(*templ));
}
i::Handle<i::ObjectTemplateInfo> result(i::ObjectTemplateInfo::cast(
Utils::OpenHandle(this)->instance_template()));
i::Handle<i::ObjectTemplateInfo> result(
i::ObjectTemplateInfo::cast(handle->instance_template()));
return Utils::ToLocal(result);
}
@ -1905,7 +1900,7 @@ Local<Script> Script::New(v8::Handle<String> source,
raw_result = *result;
}
i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
return Local<Script>(ToApi<Script>(result));
return ToApiHandle<Script>(result);
}
@ -1934,7 +1929,7 @@ Local<Script> Script::Compile(v8::Handle<String> source,
isolate->factory()->NewFunctionFromSharedFunctionInfo(
function,
isolate->global_context());
return Local<Script>(ToApi<Script>(result));
return ToApiHandle<Script>(result);
}
@ -2777,7 +2772,7 @@ Local<String> Value::ToString() const {
str = i::Execution::ToString(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
}
return Local<String>(ToApi<String>(str));
return ToApiHandle<String>(str);
}
@ -2797,7 +2792,7 @@ Local<String> Value::ToDetailString() const {
str = i::Execution::ToDetailString(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
}
return Local<String>(ToApi<String>(str));
return ToApiHandle<String>(str);
}
@ -2817,14 +2812,14 @@ Local<v8::Object> Value::ToObject() const {
val = i::Execution::ToObject(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
}
return Local<v8::Object>(ToApi<Object>(val));
return ToApiHandle<Object>(val);
}
Local<Boolean> Value::ToBoolean() const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (obj->IsBoolean()) {
return Local<Boolean>(ToApi<Boolean>(obj));
return ToApiHandle<Boolean>(obj);
} else {
i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
@ -2834,7 +2829,7 @@ Local<Boolean> Value::ToBoolean() const {
ENTER_V8(isolate);
i::Handle<i::Object> val =
isolate->factory()->ToBoolean(obj->BooleanValue());
return Local<Boolean>(ToApi<Boolean>(val));
return ToApiHandle<Boolean>(val);
}
}
@ -2855,7 +2850,7 @@ Local<Number> Value::ToNumber() const {
num = i::Execution::ToNumber(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
}
return Local<Number>(ToApi<Number>(num));
return ToApiHandle<Number>(num);
}
@ -2873,7 +2868,7 @@ Local<Integer> Value::ToInteger() const {
num = i::Execution::ToInteger(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
}
return Local<Integer>(ToApi<Integer>(num));
return ToApiHandle<Integer>(num);
}
@ -3103,7 +3098,7 @@ Local<Int32> Value::ToInt32() const {
num = i::Execution::ToInt32(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
}
return Local<Int32>(ToApi<Int32>(num));
return ToApiHandle<Int32>(num);
}
@ -3121,7 +3116,7 @@ Local<Uint32> Value::ToUint32() const {
num = i::Execution::ToUint32(obj, &has_pending_exception);
EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
}
return Local<Uint32>(ToApi<Uint32>(num));
return ToApiHandle<Uint32>(num);
}
@ -5363,7 +5358,7 @@ static i::Handle<i::Context> CreateEnvironment(
return env;
}
#ifdef V8_USE_UNSAFE_HANDLES
Persistent<Context> v8::Context::New(
v8::ExtensionConfiguration* extensions,
v8::Handle<ObjectTemplate> global_template,
@ -5380,6 +5375,7 @@ Persistent<Context> v8::Context::New(
if (env.is_null()) return Persistent<Context>();
return Persistent<Context>::New(external_isolate, Utils::ToLocal(env));
}
#endif
Local<Context> v8::Context::New(
@ -6553,24 +6549,27 @@ void Isolate::SetObjectGroupId(const Persistent<Value>& object,
UniqueId id) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
internal_isolate->global_handles()->SetObjectGroupId(
reinterpret_cast<i::Object**>(*object), id);
Utils::OpenPersistent(object).location(),
id);
}
void Isolate::SetReferenceFromGroup(UniqueId id,
const Persistent<Value>& object) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
internal_isolate->global_handles()
->SetReferenceFromGroup(id, reinterpret_cast<i::Object**>(*object));
internal_isolate->global_handles()->SetReferenceFromGroup(
id,
Utils::OpenPersistent(object).location());
}
void Isolate::SetReference(const Persistent<Object>& parent,
const Persistent<Value>& child) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
i::Object** parent_location = Utils::OpenPersistent(parent).location();
internal_isolate->global_handles()->SetReference(
i::Handle<i::HeapObject>::cast(Utils::OpenHandle(*parent)).location(),
reinterpret_cast<i::Object**>(*child));
reinterpret_cast<i::HeapObject**>(parent_location),
Utils::OpenPersistent(child).location());
}
@ -7175,12 +7174,12 @@ Handle<String> CpuProfileNode::GetFunctionName() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
const i::CodeEntry* entry = node->entry();
if (!entry->has_name_prefix()) {
return Handle<String>(ToApi<String>(
isolate->factory()->InternalizeUtf8String(entry->name())));
return ToApiHandle<String>(
isolate->factory()->InternalizeUtf8String(entry->name()));
} else {
return Handle<String>(ToApi<String>(isolate->factory()->NewConsString(
return ToApiHandle<String>(isolate->factory()->NewConsString(
isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
isolate->factory()->InternalizeUtf8String(entry->name()))));
isolate->factory()->InternalizeUtf8String(entry->name())));
}
}
@ -7189,8 +7188,8 @@ Handle<String> CpuProfileNode::GetScriptResourceName() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName");
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
node->entry()->resource_name())));
return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
node->entry()->resource_name()));
}
@ -7281,8 +7280,8 @@ Handle<String> CpuProfile::GetTitle() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
profile->title())));
return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String(
profile->title()));
}
@ -7450,12 +7449,12 @@ Handle<Value> HeapGraphEdge::GetName() const {
case i::HeapGraphEdge::kInternal:
case i::HeapGraphEdge::kProperty:
case i::HeapGraphEdge::kShortcut:
return Handle<String>(ToApi<String>(
isolate->factory()->InternalizeUtf8String(edge->name())));
return ToApiHandle<String>(
isolate->factory()->InternalizeUtf8String(edge->name()));
case i::HeapGraphEdge::kElement:
case i::HeapGraphEdge::kHidden:
return Handle<Number>(ToApi<Number>(
isolate->factory()->NewNumberFromInt(edge->index())));
return ToApiHandle<Number>(
isolate->factory()->NewNumberFromInt(edge->index()));
default: UNREACHABLE();
}
return v8::Undefined();
@ -7494,8 +7493,8 @@ HeapGraphNode::Type HeapGraphNode::GetType() const {
Handle<String> HeapGraphNode::GetName() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapGraphNode::GetName");
return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
ToInternal(this)->name())));
return ToApiHandle<String>(
isolate->factory()->InternalizeUtf8String(ToInternal(this)->name()));
}
@ -7532,9 +7531,9 @@ v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapGraphNode::GetHeapValue");
i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject();
return v8::Handle<Value>(!object.is_null() ?
ToApi<Value>(object) : ToApi<Value>(
isolate->factory()->undefined_value()));
return !object.is_null() ?
ToApiHandle<Value>(object) :
ToApiHandle<Value>(isolate->factory()->undefined_value());
}
@ -7573,8 +7572,8 @@ unsigned HeapSnapshot::GetUid() const {
Handle<String> HeapSnapshot::GetTitle() const {
i::Isolate* isolate = i::Isolate::Current();
IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
return Handle<String>(ToApi<String>(isolate->factory()->InternalizeUtf8String(
ToInternal(this)->title())));
return ToApiHandle<String>(
isolate->factory()->InternalizeUtf8String(ToInternal(this)->title()));
}

View File

@ -273,15 +273,28 @@ class Utils {
OPEN_HANDLE_LIST(DECLARE_OPEN_HANDLE)
#undef DECLARE_OPEN_HANDLE
template<class From, class To>
static inline Local<To> Convert(v8::internal::Handle<From> obj) {
ASSERT(obj.is_null() || !obj->IsTheHole());
return Local<To>(reinterpret_cast<To*>(obj.location()));
}
template <class T>
static inline v8::internal::Handle<v8::internal::Object> OpenPersistent(
const v8::Persistent<T>& persistent) {
return v8::internal::Handle<v8::internal::Object>(
reinterpret_cast<v8::internal::Object**>(persistent.val_));
}
template <class T>
static inline v8::internal::Handle<v8::internal::Object> OpenPersistent(
v8::Persistent<T>* persistent) {
return OpenPersistent(*persistent);
}
};
template <class T>
inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) {
return reinterpret_cast<T*>(obj.location());
}
template <class T>
v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom(
v8::HandleScope* scope) {
@ -293,31 +306,31 @@ v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom(
}
class InternalHandleHelper {
public:
template<class From, class To>
static inline Local<To> Convert(v8::internal::Handle<From> obj) {
return Local<To>(reinterpret_cast<To*>(obj.location()));
}
};
template <class T>
inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) {
return reinterpret_cast<T*>(obj.location());
}
template <class T>
inline v8::Local<T> ToApiHandle(
v8::internal::Handle<v8::internal::Object> obj) {
return Utils::Convert<v8::internal::Object, T>(obj);
}
// Implementations of ToLocal
#define MAKE_TO_LOCAL(Name, From, To) \
Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \
ASSERT(obj.is_null() || !obj->IsTheHole()); \
return InternalHandleHelper::Convert<v8::internal::From, v8::To>(obj); \
return Convert<v8::internal::From, v8::To>(obj); \
}
#define MAKE_TO_LOCAL_TYPED_ARRAY(TypedArray, typeConst) \
Local<v8::TypedArray> Utils::ToLocal##TypedArray( \
v8::internal::Handle<v8::internal::JSTypedArray> obj) { \
ASSERT(obj.is_null() || !obj->IsTheHole()); \
ASSERT(obj->type() == typeConst); \
return InternalHandleHelper:: \
Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \
return Convert<v8::internal::JSTypedArray, v8::TypedArray>(obj); \
}

View File

@ -82,7 +82,7 @@ v8::Handle<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) {
Object** handle = &this->end()[kReturnValueOffset];
// Nothing was set, return empty handle as per previous behaviour.
if ((*handle)->IsTheHole()) return v8::Handle<V>();
return v8::Handle<V>(reinterpret_cast<V*>(handle));
return Utils::Convert<Object, V>(Handle<Object>(handle));
}

View File

@ -68,7 +68,7 @@ void HandleDebugEvent(DebugEvent event,
// Get the toJSONProtocol function on the event and get the JSON format.
Local<String> to_json_fun_name = String::New("toJSONProtocol");
Local<Function> to_json_fun =
Function::Cast(*event_data->Get(to_json_fun_name));
Local<Function>::Cast(event_data->Get(to_json_fun_name));
Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL);
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
@ -91,9 +91,9 @@ void HandleDebugEvent(DebugEvent event,
// Get the debug command processor.
Local<String> fun_name = String::New("debugCommandProcessor");
Local<Function> fun = Function::Cast(*exec_state->Get(fun_name));
Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name));
Local<Object> cmd_processor =
Object::Cast(*fun->Call(exec_state, 0, NULL));
Local<Object>::Cast(fun->Call(exec_state, 0, NULL));
if (try_catch.HasCaught()) {
Shell::ReportException(isolate, &try_catch);
return;

View File

@ -1076,14 +1076,15 @@ static char* ReadChars(Isolate* isolate, const char* name, int* size_out) {
}
static void ReadBufferWeakCallback(v8::Isolate* isolate,
Persistent<Value>* object,
Persistent<ArrayBuffer>* array_buffer,
uint8_t* data) {
size_t byte_length = ArrayBuffer::Cast(**object)->ByteLength();
size_t byte_length =
Local<ArrayBuffer>::New(isolate, *array_buffer)->ByteLength();
isolate->AdjustAmountOfExternalAllocatedMemory(
-static_cast<intptr_t>(byte_length));
delete[] data;
object->Dispose(isolate);
array_buffer->Dispose();
}
void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
@ -1103,8 +1104,8 @@ void Shell::ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length);
v8::Persistent<v8::Value> weak_handle(isolate, buffer);
weak_handle.MakeWeak(data, ReadBufferWeakCallback);
v8::Persistent<v8::ArrayBuffer> weak_handle(isolate, buffer);
weak_handle.MakeWeak(isolate, data, ReadBufferWeakCallback);
weak_handle.MarkIndependent();
isolate->AdjustAmountOfExternalAllocatedMemory(length);

View File

@ -670,7 +670,7 @@ void ScriptCache::HandleWeakScript(v8::Isolate* isolate,
ScriptCache* script_cache = reinterpret_cast<ScriptCache*>(data);
// Find the location of the global handle.
Script** location =
reinterpret_cast<Script**>(Utils::OpenHandle(**obj).location());
reinterpret_cast<Script**>(Utils::OpenPersistent(*obj).location());
ASSERT((*location)->IsScript());
// Remove the entry from the cache.
@ -3066,13 +3066,14 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
v8::Local<v8::String> fun_name =
v8::String::New("debugCommandProcessor");
v8::Local<v8::Function> fun =
v8::Function::Cast(*api_exec_state->Get(fun_name));
v8::Local<v8::Function>::Cast(api_exec_state->Get(fun_name));
v8::Handle<v8::Boolean> running =
auto_continue ? v8::True() : v8::False();
static const int kArgc = 1;
v8::Handle<Value> argv[kArgc] = { running };
cmd_processor = v8::Object::Cast(*fun->Call(api_exec_state, kArgc, argv));
cmd_processor = v8::Local<v8::Object>::Cast(
fun->Call(api_exec_state, kArgc, argv));
if (try_catch.HasCaught()) {
PrintLn(try_catch.Exception());
return;
@ -3112,7 +3113,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
v8::Local<v8::Value> request;
v8::TryCatch try_catch;
fun_name = v8::String::New("processDebugRequest");
fun = v8::Function::Cast(*cmd_processor->Get(fun_name));
fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name));
request = v8::String::New(command.text().start(),
command.text().length());
@ -3125,7 +3126,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
if (!try_catch.HasCaught()) {
// Get response string.
if (!response_val->IsUndefined()) {
response = v8::String::Cast(*response_val);
response = v8::Local<v8::String>::Cast(response_val);
} else {
response = v8::String::New("");
}
@ -3138,7 +3139,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
// Get the running state.
fun_name = v8::String::New("isRunning");
fun = v8::Function::Cast(*cmd_processor->Get(fun_name));
fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name));
static const int kArgc = 1;
v8::Handle<Value> argv[kArgc] = { response };
v8::Local<v8::Value> running_val = fun->Call(cmd_processor, kArgc, argv);

View File

@ -347,7 +347,7 @@ Handle<Object> SetAccessor(Handle<JSObject> obj, Handle<AccessorInfo> info) {
static void ClearWrapperCache(v8::Isolate* v8_isolate,
Persistent<v8::Value>* handle,
void*) {
Handle<Object> cache = Utils::OpenHandle(**handle);
Handle<Object> cache = Utils::OpenPersistent(handle);
JSValue* wrapper = JSValue::cast(*cache);
Foreign* foreign = Script::cast(wrapper->value())->wrapper();
ASSERT(foreign->foreign_address() ==

View File

@ -435,7 +435,7 @@ void Logger::IssueCodeAddedEvent(Code* code,
event.code_len = code->instruction_size();
Handle<Script> script_handle =
script != NULL ? Handle<Script>(script) : Handle<Script>();
event.script = v8::Handle<v8::Script>(ToApi<v8::Script>(script_handle));
event.script = ToApiHandle<v8::Script>(script_handle);
event.name.str = name;
event.name.len = name_len;

View File

@ -392,7 +392,7 @@ int main(int argc, char** argv) {
// If we don't do this then we end up with a stray root pointing at the
// context even after we have disposed of the context.
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags, "mksnapshot");
i::Object* raw_context = *(v8::Utils::OpenHandle(*context));
i::Object* raw_context = *v8::Utils::OpenPersistent(context);
context.Dispose(isolate);
CppByteSink sink(argv[1]);
// This results in a somewhat smaller snapshot, probably because it gets rid

View File

@ -79,7 +79,7 @@ void TokenEnumerator::TokenRemovedCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void* parameter) {
reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved(
Utils::OpenHandle(**handle).location());
Utils::OpenPersistent(handle).location());
handle->Dispose(isolate);
}

View File

@ -655,7 +655,7 @@ static void ArrayBufferWeakCallback(v8::Isolate* external_isolate,
void* data) {
Isolate* isolate = reinterpret_cast<Isolate*>(external_isolate);
HandleScope scope(isolate);
Handle<Object> internal_object = Utils::OpenHandle(**object);
Handle<Object> internal_object = Utils::OpenPersistent(object);
Handle<JSArrayBuffer> array_buffer(JSArrayBuffer::cast(*internal_object));
if (!array_buffer->is_external()) {
@ -711,11 +711,10 @@ bool Runtime::SetupArrayBufferAllocatingData(
SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length);
v8::Isolate* external_isolate = reinterpret_cast<v8::Isolate*>(isolate);
v8::Persistent<v8::Value> weak_handle(
external_isolate, v8::Utils::ToLocal(Handle<Object>::cast(array_buffer)));
weak_handle.MakeWeak(data, ArrayBufferWeakCallback);
weak_handle.MarkIndependent(external_isolate);
Handle<Object> persistent = isolate->global_handles()->Create(*array_buffer);
GlobalHandles::MakeWeak(persistent.location(), data, ArrayBufferWeakCallback);
GlobalHandles::MarkIndependent(persistent.location());
isolate->heap()->AdjustAmountOfExternalAllocatedMemory(allocated_length);
return true;

View File

@ -48,9 +48,6 @@
#error both DEBUG and NDEBUG are set
#endif
// TODO(dcarney): remove this
#define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
// Basic includes
#include "../include/v8.h"
#include "v8globals.h"

View File

@ -200,7 +200,6 @@ class RegisterThreadedTest {
const char* name_;
};
namespace v8 {
// A LocalContext holds a reference to a v8::Context.
class LocalContext {
public:
@ -209,24 +208,27 @@ class LocalContext {
v8::Handle<v8::ObjectTemplate>(),
v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
HandleScope scope(isolate);
context_.Reset(isolate,
Context::New(isolate,
extensions,
global_template,
global_object));
context_->Enter();
v8::HandleScope scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate,
extensions,
global_template,
global_object);
context_.Reset(isolate, context);
context->Enter();
// We can't do this later perhaps because of a fatal error.
isolate_ = context_->GetIsolate();
isolate_ = context->GetIsolate();
}
virtual ~LocalContext() {
context_->Exit();
context_.Dispose(isolate_);
v8::HandleScope scope(isolate_);
v8::Local<v8::Context>::New(isolate_, context_)->Exit();
context_.Dispose();
}
v8::Context* operator->() { return *context_; }
v8::Context* operator*() { return *context_; }
v8::Context* operator->() {
return *reinterpret_cast<v8::Context**>(&context_);
}
v8::Context* operator*() { return operator->(); }
bool IsReady() { return !context_.IsEmpty(); }
v8::Local<v8::Context> local() {
@ -237,8 +239,6 @@ class LocalContext {
v8::Persistent<v8::Context> context_;
v8::Isolate* isolate_;
};
}
typedef v8::LocalContext LocalContext;
static inline v8::Local<v8::Value> v8_num(double x) {
return v8::Number::New(x);

View File

@ -2630,12 +2630,12 @@ THREADED_TEST(ArrayBuffer_JSInternalToExternal) {
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::Value> result =
v8::Local<v8::Value> result =
CompileRun("var ab1 = new ArrayBuffer(2);"
"var u8_a = new Uint8Array(ab1);"
"u8_a[0] = 0xAA;"
"u8_a[1] = 0xFF; u8_a.buffer");
Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::Cast(*result);
Local<v8::ArrayBuffer> ab1 = Local<v8::ArrayBuffer>::Cast(result);
CHECK_EQ(2, static_cast<int>(ab1->ByteLength()));
CHECK(!ab1->IsExternal());
ScopedArrayBufferContents ab1_contents(ab1->Externalize());
@ -2776,25 +2776,28 @@ THREADED_TEST(ArrayBuffer_NeuteringScript) {
"var f32a = new Float32Array(ab, 4, 255);"
"var f64a = new Float64Array(ab, 8, 127);");
v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
v8::Handle<v8::ArrayBuffer> ab =
Local<v8::ArrayBuffer>::Cast(CompileRun("ab"));
v8::Handle<v8::Uint8Array> u8a(v8::Uint8Array::Cast(*CompileRun("u8a")));
v8::Handle<v8::Uint8ClampedArray> u8c(
v8::Uint8ClampedArray::Cast(*CompileRun("u8c")));
v8::Handle<v8::Int8Array> i8a(v8::Int8Array::Cast(*CompileRun("i8a")));
v8::Handle<v8::Uint8Array> u8a =
v8::Handle<v8::Uint8Array>::Cast(CompileRun("u8a"));
v8::Handle<v8::Uint8ClampedArray> u8c =
v8::Handle<v8::Uint8ClampedArray>::Cast(CompileRun("u8c"));
v8::Handle<v8::Int8Array> i8a =
v8::Handle<v8::Int8Array>::Cast(CompileRun("i8a"));
v8::Handle<v8::Uint16Array> u16a(
v8::Uint16Array::Cast(*CompileRun("u16a")));
v8::Handle<v8::Int16Array> i16a(
v8::Int16Array::Cast(*CompileRun("i16a")));
v8::Handle<v8::Uint32Array> u32a(
v8::Uint32Array::Cast(*CompileRun("u32a")));
v8::Handle<v8::Int32Array> i32a(
v8::Int32Array::Cast(*CompileRun("i32a")));
v8::Handle<v8::Float32Array> f32a(
v8::Float32Array::Cast(*CompileRun("f32a")));
v8::Handle<v8::Float64Array> f64a(
v8::Float64Array::Cast(*CompileRun("f64a")));
v8::Handle<v8::Uint16Array> u16a =
v8::Handle<v8::Uint16Array>::Cast(CompileRun("u16a"));
v8::Handle<v8::Int16Array> i16a =
v8::Handle<v8::Int16Array>::Cast(CompileRun("i16a"));
v8::Handle<v8::Uint32Array> u32a =
v8::Handle<v8::Uint32Array>::Cast(CompileRun("u32a"));
v8::Handle<v8::Int32Array> i32a =
v8::Handle<v8::Int32Array>::Cast(CompileRun("i32a"));
v8::Handle<v8::Float32Array> f32a =
v8::Handle<v8::Float32Array>::Cast(CompileRun("f32a"));
v8::Handle<v8::Float64Array> f64a =
v8::Handle<v8::Float64Array>::Cast(CompileRun("f64a"));
ScopedArrayBufferContents contents(ab->Externalize());
ab->Neuter();
@ -3102,6 +3105,11 @@ static void WeakPointerCallback(v8::Isolate* isolate,
}
static UniqueId MakeUniqueId(const Persistent<Value>& p) {
return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p)));
}
THREADED_TEST(ApiObjectGroups) {
LocalContext env;
v8::Isolate* iso = env->GetIsolate();
@ -3139,14 +3147,14 @@ THREADED_TEST(ApiObjectGroups) {
{
HandleScope scope(iso);
CHECK(Local<Object>::New(iso, g1s2.As<Object>())->
Set(0, Local<Value>(*g2s2)));
Set(0, Local<Value>::New(iso, g2s2)));
CHECK(Local<Object>::New(iso, g2s1.As<Object>())->
Set(0, Local<Value>(*g1s1)));
Set(0, Local<Value>::New(iso, g1s1)));
}
{
UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
UniqueId id2(reinterpret_cast<intptr_t>(*g2s2));
UniqueId id1 = MakeUniqueId(g1s1);
UniqueId id2 = MakeUniqueId(g2s2);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g1c1);
@ -3171,8 +3179,8 @@ THREADED_TEST(ApiObjectGroups) {
// Groups are deleted, rebuild groups.
{
UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
UniqueId id2(reinterpret_cast<intptr_t>(*g2s2));
UniqueId id1 = MakeUniqueId(g1s1);
UniqueId id2 = MakeUniqueId(g2s2);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g1c1);
@ -3248,10 +3256,10 @@ THREADED_TEST(ApiObjectGroupsCycle) {
// G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
// groups.
{
UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
UniqueId id2(reinterpret_cast<intptr_t>(*g2s1));
UniqueId id3(reinterpret_cast<intptr_t>(*g3s1));
UniqueId id4(reinterpret_cast<intptr_t>(*g4s1));
UniqueId id1 = MakeUniqueId(g1s1);
UniqueId id2 = MakeUniqueId(g2s1);
UniqueId id3 = MakeUniqueId(g3s1);
UniqueId id4 = MakeUniqueId(g4s1);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g2s1);
@ -3278,10 +3286,10 @@ THREADED_TEST(ApiObjectGroupsCycle) {
// Groups are deleted, rebuild groups.
{
UniqueId id1(reinterpret_cast<intptr_t>(*g1s1));
UniqueId id2(reinterpret_cast<intptr_t>(*g2s1));
UniqueId id3(reinterpret_cast<intptr_t>(*g3s1));
UniqueId id4(reinterpret_cast<intptr_t>(*g4s1));
UniqueId id1 = MakeUniqueId(g1s1);
UniqueId id2 = MakeUniqueId(g2s1);
UniqueId id3 = MakeUniqueId(g3s1);
UniqueId id4 = MakeUniqueId(g4s1);
iso->SetObjectGroupId(g1s1, id1);
iso->SetObjectGroupId(g1s2, id1);
iso->SetReferenceFromGroup(id1, g2s1);
@ -3356,16 +3364,16 @@ TEST(ApiObjectGroupsCycleForScavenger) {
g3s2.MarkPartiallyDependent(iso);
iso->SetObjectGroupId(g1s1, UniqueId(1));
iso->SetObjectGroupId(g1s2, UniqueId(1));
Local<Object>::New(iso, g1s1.As<Object>())->Set(v8_str("x"),
Local<Value>(*g2s1));
Local<Object>::New(iso, g1s1.As<Object>())->Set(
v8_str("x"), Local<Value>::New(iso, g2s1));
iso->SetObjectGroupId(g2s1, UniqueId(2));
iso->SetObjectGroupId(g2s2, UniqueId(2));
Local<Object>::New(iso, g2s1.As<Object>())->Set(v8_str("x"),
Local<Value>(*g3s1));
Local<Object>::New(iso, g2s1.As<Object>())->Set(
v8_str("x"), Local<Value>::New(iso, g3s1));
iso->SetObjectGroupId(g3s1, UniqueId(3));
iso->SetObjectGroupId(g3s2, UniqueId(3));
Local<Object>::New(iso, g3s1.As<Object>())->Set(v8_str("x"),
Local<Value>(*g1s1));
Local<Object>::New(iso, g3s1.As<Object>())->Set(
v8_str("x"), Local<Value>::New(iso, g1s1));
}
v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>(
@ -3391,16 +3399,16 @@ TEST(ApiObjectGroupsCycleForScavenger) {
g3s2.MarkPartiallyDependent(isolate);
iso->SetObjectGroupId(g1s1, UniqueId(1));
iso->SetObjectGroupId(g1s2, UniqueId(1));
Local<Object>::New(iso, g1s1.As<Object>())->Set(v8_str("x"),
Local<Value>(*g2s1));
Local<Object>::New(iso, g1s1.As<Object>())->Set(
v8_str("x"), Local<Value>::New(iso, g2s1));
iso->SetObjectGroupId(g2s1, UniqueId(2));
iso->SetObjectGroupId(g2s2, UniqueId(2));
Local<Object>::New(iso, g2s1.As<Object>())->Set(v8_str("x"),
Local<Value>(*g3s1));
Local<Object>::New(iso, g2s1.As<Object>())->Set(
v8_str("x"), Local<Value>::New(iso, g3s1));
iso->SetObjectGroupId(g3s1, UniqueId(3));
iso->SetObjectGroupId(g3s2, UniqueId(3));
Local<Object>::New(iso, g3s1.As<Object>())->Set(v8_str("x"),
Local<Value>(*g1s1));
Local<Object>::New(iso, g3s1.As<Object>())->Set(
v8_str("x"), Local<Value>::New(iso, g1s1));
}
heap->CollectGarbage(i::NEW_SPACE);
@ -4853,7 +4861,7 @@ THREADED_TEST(SimplePropertyWrite) {
for (int i = 0; i < 10; i++) {
CHECK(xValue.IsEmpty());
script->Run();
CHECK_EQ(v8_num(4), Handle<Value>(*xValue));
CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
xValue.Dispose(context->GetIsolate());
xValue.Clear();
}
@ -4870,7 +4878,7 @@ THREADED_TEST(SetterOnly) {
for (int i = 0; i < 10; i++) {
CHECK(xValue.IsEmpty());
script->Run();
CHECK_EQ(v8_num(4), Handle<Value>(*xValue));
CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
xValue.Dispose(context->GetIsolate());
xValue.Clear();
}
@ -5095,7 +5103,7 @@ Handle<v8::Array> UnboxedDoubleIndexedPropertyEnumerator(
"for(i = 0; i < 80000; i++) { keys[i] = i; };"
"keys.length = 25; keys;"));
Local<Value> result = indexed_property_names_script->Run();
return Local<v8::Array>(::v8::Array::Cast(*result));
return Local<v8::Array>::Cast(result);
}
@ -5135,8 +5143,9 @@ Handle<v8::Array> NonStrictArgsIndexedPropertyEnumerator(
"}"
"keys = f(0, 1, 2, 3);"
"keys;"));
Local<Value> result = indexed_property_names_script->Run();
return Local<v8::Array>(static_cast<v8::Array*>(::v8::Object::Cast(*result)));
Local<Object> result =
Local<Object>::Cast(indexed_property_names_script->Run());
return *reinterpret_cast<Local<v8::Array>*>(&result);
}
@ -6247,7 +6256,7 @@ class Whammy {
~Whammy() { script_.Dispose(isolate_); }
v8::Handle<Script> getScript() {
if (script_.IsEmpty()) script_.Reset(isolate_, v8_compile("({}).blammo"));
return Local<Script>(*script_);
return Local<Script>::New(isolate_, script_);
}
public:
@ -7209,12 +7218,12 @@ THREADED_TEST(Utf16Symbol) {
Local<Value> s2 = global->Get(v8_str("sym2"));
Local<Value> s3 = global->Get(v8_str("sym3"));
Local<Value> s4 = global->Get(v8_str("sym4"));
CHECK(SameSymbol(sym0, Handle<String>(String::Cast(*s0))));
CHECK(SameSymbol(sym0b, Handle<String>(String::Cast(*s0b))));
CHECK(SameSymbol(sym1, Handle<String>(String::Cast(*s1))));
CHECK(SameSymbol(sym2, Handle<String>(String::Cast(*s2))));
CHECK(SameSymbol(sym3, Handle<String>(String::Cast(*s3))));
CHECK(SameSymbol(sym4, Handle<String>(String::Cast(*s4))));
CHECK(SameSymbol(sym0, Handle<String>::Cast(s0)));
CHECK(SameSymbol(sym0b, Handle<String>::Cast(s0b)));
CHECK(SameSymbol(sym1, Handle<String>::Cast(s1)));
CHECK(SameSymbol(sym2, Handle<String>::Cast(s2)));
CHECK(SameSymbol(sym3, Handle<String>::Cast(s3)));
CHECK(SameSymbol(sym4, Handle<String>::Cast(s4)));
}
@ -12201,7 +12210,7 @@ void HandleCreatingCallback(v8::Isolate* isolate,
v8::Persistent<v8::Value>* handle,
void*) {
v8::HandleScope scope(isolate);
v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
v8::Persistent<v8::Object>(isolate, v8::Object::New());
handle->Dispose(isolate);
}
@ -19293,10 +19302,10 @@ THREADED_TEST(Regress2535) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
Local<Value> set_value = CompileRun("new Set();");
Local<Object> set_object(Object::Cast(*set_value));
Local<Object> set_object(Local<Object>::Cast(set_value));
CHECK_EQ(0, set_object->InternalFieldCount());
Local<Value> map_value = CompileRun("new Map();");
Local<Object> map_object(Object::Cast(*map_value));
Local<Object> map_object(Local<Object>::Cast(map_value));
CHECK_EQ(0, map_object->InternalFieldCount());
}

View File

@ -143,6 +143,7 @@ class DebugLocalContext {
inline ~DebugLocalContext() {
context_->Exit();
}
inline v8::Local<v8::Context> context() { return context_; }
inline v8::Context* operator->() { return *context_; }
inline v8::Context* operator*() { return *context_; }
inline bool IsReady() { return !context_.IsEmpty(); }
@ -788,8 +789,8 @@ static void DebugEventCounter(v8::DebugEvent event,
// Check whether the exception was uncaught.
v8::Local<v8::String> fun_name = v8::String::New("uncaught");
v8::Local<v8::Function> fun =
v8::Function::Cast(*event_data->Get(fun_name));
v8::Local<v8::Value> result = *fun->Call(event_data, 0, NULL);
v8::Local<v8::Function>::Cast(event_data->Get(fun_name));
v8::Local<v8::Value> result = fun->Call(event_data, 0, NULL);
if (result->IsTrue()) {
uncaught_exception_hit_count++;
}
@ -6457,7 +6458,7 @@ static void ExecuteScriptForContextCheck() {
// Enter and run function in the context.
{
v8::Context::Scope context_scope(context_1);
expected_context = v8::Local<v8::Context>(*context_1);
expected_context = context_1;
expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_1->Global(), 0, NULL);
@ -7041,11 +7042,11 @@ static void DebugEventGetAtgumentPropertyValue(
if (event == v8::Break) {
break_point_hit_count++;
CHECK(debugger_context == v8::Context::GetCurrent());
v8::Handle<v8::Function> func(v8::Function::Cast(*CompileRun(
v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(CompileRun(
"(function(exec_state) {\n"
" return (exec_state.frame(0).argumentValue(0).property('a').\n"
" value().value() == 1);\n"
"})")));
"})"));
const int argc = 1;
v8::Handle<v8::Value> argv[argc] = { exec_state };
v8::Handle<v8::Value> result = func->Call(exec_state, argc, argv);
@ -7063,7 +7064,7 @@ TEST(CallingContextIsNotDebugContext) {
// Save handles to the debugger and debugee contexts to be used in
// NamedGetterWithCallingContextCheck.
debugee_context = v8::Local<v8::Context>(*env);
debugee_context = env.context();
debugger_context = v8::Utils::ToLocal(debug->debug_context());
// Create object with 'a' property accessor.

View File

@ -120,8 +120,8 @@ static void VerifyRead(v8::Handle<v8::DeclaredAccessorDescriptor> descriptor,
CreateConstructor(context, "Accessible", internal_field, "x", descriptor);
// Setup object.
CompileRun("var accessible = new Accessible();");
v8::Local<v8::Object> obj(
v8::Object::Cast(*context->Global()->Get(v8_str("accessible"))));
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
context->Global()->Get(v8_str("accessible")));
obj->SetAlignedPointerInInternalField(internal_field, internal_object);
bool added_accessor;
added_accessor = obj->SetAccessor(v8_str("y"), descriptor);

View File

@ -36,7 +36,7 @@ using namespace v8;
TEST(StrictUndeclaredGlobalVariable) {
HandleScope scope(Isolate::GetCurrent());
v8::Local<v8::String> var_name = v8_str("x");
v8::LocalContext context;
LocalContext context;
v8::TryCatch try_catch;
v8::Local<v8::Script> script = v8_compile("\"use strict\"; x = 42;");
v8::Handle<v8::Object> proto = v8::Object::New();

View File

@ -405,8 +405,7 @@ TEST(LogCallbacks) {
v8::FunctionTemplate::New());
obj->SetClassName(v8_str("Obj"));
v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
v8::Local<v8::Signature> signature =
v8::Signature::New(v8::Handle<v8::FunctionTemplate>(*obj));
v8::Local<v8::Signature> signature = v8::Signature::New(obj);
proto->Set(v8_str("method1"),
v8::FunctionTemplate::New(ObjMethod1,
v8::Handle<v8::Value>(),

View File

@ -57,7 +57,7 @@ class HarmonyIsolate {
TEST(PerIsolateState) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context1;
LocalContext context1;
CompileRun(
"var count = 0;"
"var calls = 0;"
@ -70,20 +70,20 @@ TEST(PerIsolateState) {
"(function() { obj.foo = 'bar'; })");
Handle<Value> notify_fun2;
{
v8::LocalContext context2;
LocalContext context2;
context2->Global()->Set(String::New("obj"), obj);
notify_fun2 = CompileRun(
"(function() { obj.foo = 'baz'; })");
}
Handle<Value> notify_fun3;
{
v8::LocalContext context3;
LocalContext context3;
context3->Global()->Set(String::New("obj"), obj);
notify_fun3 = CompileRun(
"(function() { obj.foo = 'bat'; })");
}
{
v8::LocalContext context4;
LocalContext context4;
context4->Global()->Set(String::New("observer"), observer);
context4->Global()->Set(String::New("fun1"), notify_fun1);
context4->Global()->Set(String::New("fun2"), notify_fun2);
@ -97,7 +97,7 @@ TEST(PerIsolateState) {
TEST(EndOfMicrotaskDelivery) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context;
LocalContext context;
CompileRun(
"var obj = {};"
"var count = 0;"
@ -110,7 +110,7 @@ TEST(EndOfMicrotaskDelivery) {
TEST(DeliveryOrdering) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context;
LocalContext context;
CompileRun(
"var obj1 = {};"
"var obj2 = {};"
@ -141,7 +141,7 @@ TEST(DeliveryOrdering) {
TEST(DeliveryOrderingReentrant) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context;
LocalContext context;
CompileRun(
"var obj = {};"
"var reentered = false;"
@ -172,7 +172,7 @@ TEST(DeliveryOrderingReentrant) {
TEST(DeliveryOrderingDeliverChangeRecords) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context;
LocalContext context;
CompileRun(
"var obj = {};"
"var ordering = [];"
@ -197,14 +197,14 @@ TEST(ObjectHashTableGrowth) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
// Initializing this context sets up initial hash tables.
v8::LocalContext context;
LocalContext context;
Handle<Value> obj = CompileRun("obj = {};");
Handle<Value> observer = CompileRun(
"var ran = false;"
"(function() { ran = true })");
{
// As does initializing this context.
v8::LocalContext context2;
LocalContext context2;
context2->Global()->Set(String::New("obj"), obj);
context2->Global()->Set(String::New("observer"), observer);
CompileRun(
@ -224,7 +224,7 @@ TEST(ObjectHashTableGrowth) {
TEST(GlobalObjectObservation) {
HarmonyIsolate isolate;
v8::LocalContext context;
LocalContext context;
HandleScope scope(isolate.GetIsolate());
Handle<Object> global_proxy = context->Global();
Handle<Object> inner_global = global_proxy->GetPrototype().As<Object>();
@ -256,7 +256,7 @@ TEST(GlobalObjectObservation) {
// to the old context.
context->DetachGlobal();
{
v8::LocalContext context2;
LocalContext context2;
context2->DetachGlobal();
context2->ReattachGlobal(global_proxy);
CompileRun(
@ -271,7 +271,7 @@ TEST(GlobalObjectObservation) {
// Attaching by passing to Context::New
{
// Delegates to Context::New
v8::LocalContext context3(NULL, Handle<ObjectTemplate>(), global_proxy);
LocalContext context3(NULL, Handle<ObjectTemplate>(), global_proxy);
CompileRun(
"var records3 = [];"
"Object.observe(this, function(r) { [].push.apply(records3, r) });"
@ -320,7 +320,7 @@ static void ExpectRecords(Handle<Value> records,
TEST(APITestBasicMutation) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context;
LocalContext context;
Handle<Object> obj = Handle<Object>::Cast(CompileRun(
"var records = [];"
"var obj = {};"
@ -363,7 +363,7 @@ TEST(APITestBasicMutation) {
TEST(HiddenPrototypeObservation) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context;
LocalContext context;
Handle<FunctionTemplate> tmpl = FunctionTemplate::New();
tmpl->SetHiddenPrototype(true);
tmpl->InstanceTemplate()->Set(String::New("foo"), Number::New(75));
@ -412,7 +412,7 @@ static int NumberOfElements(i::Handle<i::JSWeakMap> map) {
TEST(ObservationWeakMap) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
v8::LocalContext context;
LocalContext context;
CompileRun(
"var obj = {};"
"Object.observe(obj, function(){});"

View File

@ -556,7 +556,7 @@ TEST(ContextSerialization) {
v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
}
Object* raw_context = *(v8::Utils::OpenHandle(*env));
i::Object* raw_context = *v8::Utils::OpenPersistent(env);
env.Dispose(v8_isolate);

View File

@ -137,12 +137,12 @@ TEST(WeakArrayBuffersFromScript) {
CompileRun("var ab1 = new ArrayBuffer(256);"
"var ab2 = new ArrayBuffer(256);"
"var ab3 = new ArrayBuffer(256);");
v8::Handle<v8::ArrayBuffer> ab1(
v8::ArrayBuffer::Cast(*CompileRun("ab1")));
v8::Handle<v8::ArrayBuffer> ab2(
v8::ArrayBuffer::Cast(*CompileRun("ab2")));
v8::Handle<v8::ArrayBuffer> ab3(
v8::ArrayBuffer::Cast(*CompileRun("ab3")));
v8::Handle<v8::ArrayBuffer> ab1 =
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab1"));
v8::Handle<v8::ArrayBuffer> ab2 =
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab2"));
v8::Handle<v8::ArrayBuffer> ab3 =
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab3"));
CHECK_EQ(3, CountArrayBuffersInWeakList(isolate->heap()));
CHECK(HasArrayBufferInWeakList(isolate->heap(),
@ -166,8 +166,8 @@ TEST(WeakArrayBuffersFromScript) {
for (int j = 1; j <= 3; j++) {
if (j == i) continue;
i::OS::SNPrintF(source, "ab%d", j);
v8::Handle<v8::ArrayBuffer> ab(
v8::ArrayBuffer::Cast(*CompileRun(source.start())));
v8::Handle<v8::ArrayBuffer> ab =
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun(source.start()));
CHECK(HasArrayBufferInWeakList(isolate->heap(),
*v8::Utils::OpenHandle(*ab)));
}
@ -285,10 +285,14 @@ static void TestTypedArrayFromScript(const char* constructor) {
constructor, constructor, constructor);
CompileRun(source.start());
v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
v8::Handle<TypedArray> ta1(TypedArray::Cast(*CompileRun("ta1")));
v8::Handle<TypedArray> ta2(TypedArray::Cast(*CompileRun("ta2")));
v8::Handle<TypedArray> ta3(TypedArray::Cast(*CompileRun("ta3")));
v8::Handle<v8::ArrayBuffer> ab =
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
v8::Handle<TypedArray> ta1 =
v8::Handle<TypedArray>::Cast(CompileRun("ta1"));
v8::Handle<TypedArray> ta2 =
v8::Handle<TypedArray>::Cast(CompileRun("ta2"));
v8::Handle<TypedArray> ta3 =
v8::Handle<TypedArray>::Cast(CompileRun("ta3"));
CHECK_EQ(1, CountArrayBuffersInWeakList(isolate->heap()));
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
CHECK_EQ(3, CountTypedArrays(*iab));
@ -306,14 +310,15 @@ static void TestTypedArrayFromScript(const char* constructor) {
{
v8::HandleScope s2(context->GetIsolate());
v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
v8::Handle<v8::ArrayBuffer> ab =
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
CHECK_EQ(2, CountTypedArrays(*iab));
for (int j = 1; j <= 3; j++) {
if (j == i) continue;
i::OS::SNPrintF(source, "ta%d", j);
v8::Handle<TypedArray> ta(
TypedArray::Cast(*CompileRun(source.start())));
v8::Handle<TypedArray> ta =
v8::Handle<TypedArray>::Cast(CompileRun(source.start()));
CHECK(HasTypedArrayInWeakList(*iab, *v8::Utils::OpenHandle(*ta)));
}
}
@ -326,7 +331,8 @@ static void TestTypedArrayFromScript(const char* constructor) {
{
v8::HandleScope s3(context->GetIsolate());
v8::Handle<v8::ArrayBuffer> ab(v8::ArrayBuffer::Cast(*CompileRun("ab")));
v8::Handle<v8::ArrayBuffer> ab =
v8::Handle<v8::ArrayBuffer>::Cast(CompileRun("ab"));
Handle<JSArrayBuffer> iab = v8::Utils::OpenHandle(*ab);
CHECK_EQ(0, CountTypedArrays(*iab));
}