Commit 8b2c26d7 authored by dcarney@chromium.org's avatar dcarney@chromium.org

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
parent 28db1d0e
......@@ -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));
}
......
This diff is collapsed.
......@@ -273,13 +273,26 @@ 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>
inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) {
return reinterpret_cast<T*>(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>
......@@ -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); \
}
......
......@@ -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));
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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() ==
......
......@@ -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;
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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"
......
......@@ -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);
......
This diff is collapsed.
......@@ -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.
......
......@@ -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);
......
......@@ -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();
......
......@@ -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>(),
......
......@@ -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(){});"
......
......@@ -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);
......
......@@ -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));
}
......
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