Removed internal uses of (almost) deprecated FunctionTemplate::New version.

LOG=y
R=dcarney@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18342 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2013-12-18 10:31:42 +00:00
parent 7be4945c2b
commit 389ee8d59b
26 changed files with 667 additions and 511 deletions

View File

@ -204,12 +204,12 @@ int RunMain(int argc, char* argv[]) {
// Bind the global 'print' function to the C++ Print callback.
global->Set(v8::String::NewFromUtf8(isolate, "print"),
v8::FunctionTemplate::New(Print));
v8::FunctionTemplate::New(isolate, Print));
if (cycle_type == CycleInJs) {
// Bind the global 'read_line' function to the C++ Print callback.
global->Set(v8::String::NewFromUtf8(isolate, "read_line"),
v8::FunctionTemplate::New(ReadLine));
v8::FunctionTemplate::New(isolate, ReadLine));
}
// Create a new execution environment containing the built-in

View File

@ -162,7 +162,7 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
// built-in global functions.
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::NewFromUtf8(GetIsolate(), "log"),
FunctionTemplate::New(LogCallback));
FunctionTemplate::New(GetIsolate(), LogCallback));
// Each processor gets its own context so different processors don't
// affect each other. Context::New returns a persistent handle which

View File

@ -101,19 +101,19 @@ v8::Handle<v8::Context> CreateShellContext(v8::Isolate* isolate) {
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
// Bind the global 'print' function to the C++ Print callback.
global->Set(v8::String::NewFromUtf8(isolate, "print"),
v8::FunctionTemplate::New(Print));
v8::FunctionTemplate::New(isolate, Print));
// Bind the global 'read' function to the C++ Read callback.
global->Set(v8::String::NewFromUtf8(isolate, "read"),
v8::FunctionTemplate::New(Read));
v8::FunctionTemplate::New(isolate, Read));
// Bind the global 'load' function to the C++ Load callback.
global->Set(v8::String::NewFromUtf8(isolate, "load"),
v8::FunctionTemplate::New(Load));
v8::FunctionTemplate::New(isolate, Load));
// Bind the 'quit' function
global->Set(v8::String::NewFromUtf8(isolate, "quit"),
v8::FunctionTemplate::New(Quit));
v8::FunctionTemplate::New(isolate, Quit));
// Bind the 'version' function
global->Set(v8::String::NewFromUtf8(isolate, "version"),
v8::FunctionTemplate::New(Version));
v8::FunctionTemplate::New(isolate, Version));
return v8::Context::New(isolate, NULL, global);
}

View File

@ -1368,13 +1368,15 @@ Local<ObjectTemplate> ObjectTemplate::New(
// Ensure that the object template has a constructor. If no
// constructor is available we create one.
static i::Handle<i::FunctionTemplateInfo> EnsureConstructor(
i::Isolate* isolate,
ObjectTemplate* object_template) {
i::Object* obj = Utils::OpenHandle(object_template)->constructor();
if (!obj ->IsUndefined()) {
i::FunctionTemplateInfo* info = i::FunctionTemplateInfo::cast(obj);
return i::Handle<i::FunctionTemplateInfo>(info, info->GetIsolate());
return i::Handle<i::FunctionTemplateInfo>(info, isolate);
}
Local<FunctionTemplate> templ = FunctionTemplate::New();
Local<FunctionTemplate> templ =
FunctionTemplate::New(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::FunctionTemplateInfo> constructor = Utils::OpenHandle(*templ);
constructor->set_instance_template(*Utils::OpenHandle(object_template));
Utils::OpenHandle(object_template)->set_constructor(*constructor);
@ -1396,6 +1398,7 @@ static inline void AddPropertyToTemplate(
static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
i::Isolate* isolate,
Template* template_obj) {
return Utils::OpenHandle(template_obj);
}
@ -1403,8 +1406,9 @@ static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
// TODO(dcarney): remove this with ObjectTemplate::SetAccessor
static inline i::Handle<i::TemplateInfo> GetTemplateInfo(
i::Isolate* isolate,
ObjectTemplate* object_template) {
EnsureConstructor(object_template);
EnsureConstructor(isolate, object_template);
return Utils::OpenHandle(object_template);
}
@ -1425,7 +1429,7 @@ static bool TemplateSetAccessor(
i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(
name, getter, setter, data, settings, attribute, signature);
if (obj.is_null()) return false;
i::Handle<i::TemplateInfo> info = GetTemplateInfo(template_obj);
i::Handle<i::TemplateInfo> info = GetTemplateInfo(isolate, template_obj);
AddPropertyToTemplate(info, obj);
return true;
}
@ -1477,7 +1481,7 @@ void ObjectTemplate::SetNamedPropertyHandler(
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
EnsureConstructor(this);
EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@ -1504,7 +1508,7 @@ void ObjectTemplate::MarkAsUndetectable() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
EnsureConstructor(this);
EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor =
i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@ -1520,7 +1524,7 @@ void ObjectTemplate::SetAccessCheckCallbacks(
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
EnsureConstructor(this);
EnsureConstructor(isolate, this);
i::Handle<i::Struct> struct_info =
isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE);
@ -1553,7 +1557,7 @@ void ObjectTemplate::SetIndexedPropertyHandler(
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
EnsureConstructor(this);
EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@ -1581,7 +1585,7 @@ void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback,
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
i::HandleScope scope(isolate);
EnsureConstructor(this);
EnsureConstructor(isolate, this);
i::FunctionTemplateInfo* constructor = i::FunctionTemplateInfo::cast(
Utils::OpenHandle(this)->constructor());
i::Handle<i::FunctionTemplateInfo> cons(constructor);
@ -1615,7 +1619,7 @@ void ObjectTemplate::SetInternalFieldCount(int value) {
// The internal field count is set by the constructor function's
// construct code, so we ensure that there is a constructor
// function to do the setting.
EnsureConstructor(this);
EnsureConstructor(isolate, this);
}
Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
}
@ -5140,11 +5144,11 @@ static i::Handle<i::Context> CreateEnvironment(
if (!global_template.IsEmpty()) {
// Make sure that the global_template has a constructor.
global_constructor = EnsureConstructor(*global_template);
global_constructor = EnsureConstructor(isolate, *global_template);
// Create a fresh template for the global proxy object.
proxy_template = ObjectTemplate::New();
proxy_constructor = EnsureConstructor(*proxy_template);
proxy_constructor = EnsureConstructor(isolate, *proxy_template);
// Set the global template to be the prototype template of
// global proxy template.

View File

@ -723,19 +723,19 @@ void Shell::UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::AddOSMethods(Isolate* isolate, Handle<ObjectTemplate> os_templ) {
os_templ->Set(String::NewFromUtf8(isolate, "system"),
FunctionTemplate::New(System));
FunctionTemplate::New(isolate, System));
os_templ->Set(String::NewFromUtf8(isolate, "chdir"),
FunctionTemplate::New(ChangeDirectory));
FunctionTemplate::New(isolate, ChangeDirectory));
os_templ->Set(String::NewFromUtf8(isolate, "setenv"),
FunctionTemplate::New(SetEnvironment));
FunctionTemplate::New(isolate, SetEnvironment));
os_templ->Set(String::NewFromUtf8(isolate, "unsetenv"),
FunctionTemplate::New(UnsetEnvironment));
FunctionTemplate::New(isolate, UnsetEnvironment));
os_templ->Set(String::NewFromUtf8(isolate, "umask"),
FunctionTemplate::New(SetUMask));
FunctionTemplate::New(isolate, SetUMask));
os_templ->Set(String::NewFromUtf8(isolate, "mkdirp"),
FunctionTemplate::New(MakeDirectory));
FunctionTemplate::New(isolate, MakeDirectory));
os_templ->Set(String::NewFromUtf8(isolate, "rmdir"),
FunctionTemplate::New(RemoveDirectory));
FunctionTemplate::New(isolate, RemoveDirectory));
}
} // namespace v8

View File

@ -860,38 +860,38 @@ class BZip2Decompressor : public v8::StartupDataDecompressor {
Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
Handle<ObjectTemplate> global_template = ObjectTemplate::New();
global_template->Set(String::NewFromUtf8(isolate, "print"),
FunctionTemplate::New(Print));
FunctionTemplate::New(isolate, Print));
global_template->Set(String::NewFromUtf8(isolate, "write"),
FunctionTemplate::New(Write));
FunctionTemplate::New(isolate, Write));
global_template->Set(String::NewFromUtf8(isolate, "read"),
FunctionTemplate::New(Read));
FunctionTemplate::New(isolate, Read));
global_template->Set(String::NewFromUtf8(isolate, "readbuffer"),
FunctionTemplate::New(ReadBuffer));
FunctionTemplate::New(isolate, ReadBuffer));
global_template->Set(String::NewFromUtf8(isolate, "readline"),
FunctionTemplate::New(ReadLine));
FunctionTemplate::New(isolate, ReadLine));
global_template->Set(String::NewFromUtf8(isolate, "load"),
FunctionTemplate::New(Load));
FunctionTemplate::New(isolate, Load));
global_template->Set(String::NewFromUtf8(isolate, "quit"),
FunctionTemplate::New(Quit));
FunctionTemplate::New(isolate, Quit));
global_template->Set(String::NewFromUtf8(isolate, "version"),
FunctionTemplate::New(Version));
FunctionTemplate::New(isolate, Version));
// Bind the Realm object.
Handle<ObjectTemplate> realm_template = ObjectTemplate::New();
realm_template->Set(String::NewFromUtf8(isolate, "current"),
FunctionTemplate::New(RealmCurrent));
FunctionTemplate::New(isolate, RealmCurrent));
realm_template->Set(String::NewFromUtf8(isolate, "owner"),
FunctionTemplate::New(RealmOwner));
FunctionTemplate::New(isolate, RealmOwner));
realm_template->Set(String::NewFromUtf8(isolate, "global"),
FunctionTemplate::New(RealmGlobal));
FunctionTemplate::New(isolate, RealmGlobal));
realm_template->Set(String::NewFromUtf8(isolate, "create"),
FunctionTemplate::New(RealmCreate));
FunctionTemplate::New(isolate, RealmCreate));
realm_template->Set(String::NewFromUtf8(isolate, "dispose"),
FunctionTemplate::New(RealmDispose));
FunctionTemplate::New(isolate, RealmDispose));
realm_template->Set(String::NewFromUtf8(isolate, "switch"),
FunctionTemplate::New(RealmSwitch));
FunctionTemplate::New(isolate, RealmSwitch));
realm_template->Set(String::NewFromUtf8(isolate, "eval"),
FunctionTemplate::New(RealmEval));
FunctionTemplate::New(isolate, RealmEval));
realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"),
RealmSharedGet, RealmSharedSet);
global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template);
@ -899,7 +899,7 @@ Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
#ifndef V8_SHARED
Handle<ObjectTemplate> performance_template = ObjectTemplate::New();
performance_template->Set(String::NewFromUtf8(isolate, "now"),
FunctionTemplate::New(PerformanceNow));
FunctionTemplate::New(isolate, PerformanceNow));
global_template->Set(String::NewFromUtf8(isolate, "performance"),
performance_template);
#endif // V8_SHARED

View File

@ -64,10 +64,12 @@ v8::Handle<v8::FunctionTemplate>
ExternalizeStringExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<v8::String> str) {
if (strcmp(*v8::String::Utf8Value(str), "externalizeString") == 0) {
return v8::FunctionTemplate::New(ExternalizeStringExtension::Externalize);
return v8::FunctionTemplate::New(isolate,
ExternalizeStringExtension::Externalize);
} else {
ASSERT(strcmp(*v8::String::Utf8Value(str), "isAsciiString") == 0);
return v8::FunctionTemplate::New(ExternalizeStringExtension::IsAscii);
return v8::FunctionTemplate::New(isolate,
ExternalizeStringExtension::IsAscii);
}
}

View File

@ -36,7 +36,7 @@ namespace internal {
v8::Handle<v8::FunctionTemplate> FreeBufferExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
return v8::FunctionTemplate::New(FreeBufferExtension::FreeBuffer);
return v8::FunctionTemplate::New(isolate, FreeBufferExtension::FreeBuffer);
}

View File

@ -35,7 +35,7 @@ namespace internal {
v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
return v8::FunctionTemplate::New(GCExtension::GC);
return v8::FunctionTemplate::New(isolate, GCExtension::GC);
}

View File

@ -38,7 +38,7 @@ v8::Handle<v8::FunctionTemplate> StatisticsExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
ASSERT(strcmp(*v8::String::Utf8Value(str), "getV8Statistics") == 0);
return v8::FunctionTemplate::New(StatisticsExtension::GetCounters);
return v8::FunctionTemplate::New(isolate, StatisticsExtension::GetCounters);
}

View File

@ -44,13 +44,16 @@ TriggerFailureExtension::GetNativeFunctionTemplate(
v8::Handle<v8::String> str) {
if (strcmp(*v8::String::Utf8Value(str), "triggerCheckFalse") == 0) {
return v8::FunctionTemplate::New(
isolate,
TriggerFailureExtension::TriggerCheckFalse);
} else if (strcmp(*v8::String::Utf8Value(str), "triggerAssertFalse") == 0) {
return v8::FunctionTemplate::New(
isolate,
TriggerFailureExtension::TriggerAssertFalse);
} else {
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(str), "triggerSlowAssertFalse"));
return v8::FunctionTemplate::New(
isolate,
TriggerFailureExtension::TriggerSlowAssertFalse);
}
}

View File

@ -65,11 +65,12 @@ static void handle_property(const v8::FunctionCallbackInfo<v8::Value>& info) {
THREADED_TEST(PropertyHandler) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(isolate);
fun_templ->InstanceTemplate()->SetAccessor(v8_str("foo"), handle_property);
Local<v8::FunctionTemplate> getter_templ =
v8::FunctionTemplate::New(handle_property);
v8::FunctionTemplate::New(isolate, handle_property);
getter_templ->SetLength(0);
fun_templ->
InstanceTemplate()->SetAccessorProperty(v8_str("bar"), getter_templ);
@ -120,17 +121,18 @@ THREADED_TEST(GlobalVariableAccess) {
foo = 0;
bar = -4;
baz = 10;
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->InstanceTemplate()->SetAccessor(
v8_str("foo"), GetIntValue, SetIntValue,
v8::External::New(CcTest::isolate(), &foo));
v8::External::New(isolate, &foo));
templ->InstanceTemplate()->SetAccessor(
v8_str("bar"), GetIntValue, SetIntValue,
v8::External::New(CcTest::isolate(), &bar));
v8::External::New(isolate, &bar));
templ->InstanceTemplate()->SetAccessor(
v8_str("baz"), GetIntValue, SetIntValue,
v8::External::New(CcTest::isolate(), &baz));
v8::External::New(isolate, &baz));
LocalContext env(0, templ->InstanceTemplate());
v8_compile("foo = (++bar) + baz")->Run();
CHECK_EQ(bar, -3);
@ -190,12 +192,13 @@ static void XSetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
THREADED_TEST(AccessorIC) {
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
v8::Isolate* isolate = context->GetIsolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
obj->SetAccessor(v8_str("x0"), XGetter, XSetter);
obj->SetAccessorProperty(v8_str("x1"),
v8::FunctionTemplate::New(XGetter),
v8::FunctionTemplate::New(XSetter));
v8::FunctionTemplate::New(isolate, XGetter),
v8::FunctionTemplate::New(isolate, XSetter));
x_holder = obj->NewInstance();
context->Global()->Set(v8_str("holder"), x_holder);
x_receiver = v8::Object::New();

File diff suppressed because it is too large Load Diff

View File

@ -535,7 +535,8 @@ TEST(StackAlignmentForSSE2) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(v8_str("do_sse2"), v8::FunctionTemplate::New(DoSSE2));
global_template->Set(v8_str("do_sse2"),
v8::FunctionTemplate::New(isolate, DoSSE2));
LocalContext env(NULL, global_template);
CompileRun(

View File

@ -615,7 +615,8 @@ TEST(StackAlignmentForSSE2) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(v8_str("do_sse2"), v8::FunctionTemplate::New(DoSSE2));
global_template->Set(v8_str("do_sse2"),
v8::FunctionTemplate::New(isolate, DoSSE2));
LocalContext env(NULL, global_template);
CompileRun(

View File

@ -60,7 +60,7 @@ const char* PrintExtension::kSource = "native function print();";
v8::Handle<v8::FunctionTemplate> PrintExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> str) {
return v8::FunctionTemplate::New(PrintExtension::Print);
return v8::FunctionTemplate::New(isolate, PrintExtension::Print);
}

View File

@ -716,29 +716,30 @@ class TestApiCallbacks {
// code.
TEST(NativeAccessorUninitializedIC) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(isolate);
v8::Local<v8::ObjectTemplate> instance_template =
func_template->InstanceTemplate();
TestApiCallbacks accessors(100);
v8::Local<v8::External> data =
v8::External::New(env->GetIsolate(), &accessors);
v8::External::New(isolate, &accessors);
instance_template->SetAccessor(
v8::String::NewFromUtf8(env->GetIsolate(), "foo"),
v8::String::NewFromUtf8(isolate, "foo"),
&TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source))
v8::String::NewFromUtf8(isolate, native_accessor_test_source))
->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
int32_t repeat_count = 1;
v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
@ -747,9 +748,9 @@ TEST(NativeAccessorUninitializedIC) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* startNode =
GetChild(env->GetIsolate(), root, "start");
GetChild(env->GetIsolate(), startNode, "get foo");
GetChild(env->GetIsolate(), startNode, "set foo");
GetChild(isolate, root, "start");
GetChild(isolate, startNode, "get foo");
GetChild(isolate, startNode, "set foo");
const_cast<v8::CpuProfile*>(profile)->Delete();
}
@ -760,29 +761,30 @@ TEST(NativeAccessorUninitializedIC) {
// hot and to trigger optimizations.
TEST(NativeAccessorMonomorphicIC) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(isolate);
v8::Local<v8::ObjectTemplate> instance_template =
func_template->InstanceTemplate();
TestApiCallbacks accessors(1);
v8::Local<v8::External> data =
v8::External::New(env->GetIsolate(), &accessors);
v8::External::New(isolate, &accessors);
instance_template->SetAccessor(
v8::String::NewFromUtf8(env->GetIsolate(), "foo"),
v8::String::NewFromUtf8(isolate, "foo"),
&TestApiCallbacks::Getter, &TestApiCallbacks::Setter, data);
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(
v8::String::NewFromUtf8(env->GetIsolate(), native_accessor_test_source))
v8::String::NewFromUtf8(isolate, native_accessor_test_source))
->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
{
// Make sure accessors ICs are in monomorphic state before starting
@ -801,9 +803,9 @@ TEST(NativeAccessorMonomorphicIC) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* startNode =
GetChild(env->GetIsolate(), root, "start");
GetChild(env->GetIsolate(), startNode, "get foo");
GetChild(env->GetIsolate(), startNode, "set foo");
GetChild(isolate, root, "start");
GetChild(isolate, startNode, "get foo");
GetChild(isolate, startNode, "set foo");
const_cast<v8::CpuProfile*>(profile)->Delete();
}
@ -818,32 +820,35 @@ static const char* native_method_test_source = "function start(count) {\n"
TEST(NativeMethodUninitializedIC) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
TestApiCallbacks callbacks(100);
v8::Local<v8::External> data =
v8::External::New(env->GetIsolate(), &callbacks);
v8::External::New(isolate, &callbacks);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(isolate);
func_template->SetClassName(
v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor"));
v8::Local<v8::ObjectTemplate> proto_template =
func_template->PrototypeTemplate();
v8::Local<v8::Signature> signature =
v8::Signature::New(env->GetIsolate(), func_template);
proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
v8::Signature::New(isolate, func_template);
proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"),
v8::FunctionTemplate::New(isolate,
&TestApiCallbacks::Callback,
data, signature, 0));
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(v8::String::NewFromUtf8(
env->GetIsolate(), native_method_test_source))->Run();
isolate, native_method_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
int32_t repeat_count = 1;
v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
@ -852,8 +857,8 @@ TEST(NativeMethodUninitializedIC) {
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
const v8::CpuProfileNode* startNode =
GetChild(env->GetIsolate(), root, "start");
GetChild(env->GetIsolate(), startNode, "fooMethod");
GetChild(isolate, root, "start");
GetChild(isolate, startNode, "fooMethod");
const_cast<v8::CpuProfile*>(profile)->Delete();
}
@ -861,32 +866,35 @@ TEST(NativeMethodUninitializedIC) {
TEST(NativeMethodMonomorphicIC) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
TestApiCallbacks callbacks(1);
v8::Local<v8::External> data =
v8::External::New(env->GetIsolate(), &callbacks);
v8::External::New(isolate, &callbacks);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(isolate);
func_template->SetClassName(
v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
v8::String::NewFromUtf8(isolate, "Test_InstanceCostructor"));
v8::Local<v8::ObjectTemplate> proto_template =
func_template->PrototypeTemplate();
v8::Local<v8::Signature> signature =
v8::Signature::New(env->GetIsolate(), func_template);
proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
v8::Signature::New(isolate, func_template);
proto_template->Set(v8::String::NewFromUtf8(isolate, "fooMethod"),
v8::FunctionTemplate::New(isolate,
&TestApiCallbacks::Callback,
data, signature, 0));
v8::Local<v8::Function> func = func_template->GetFunction();
v8::Local<v8::Object> instance = func->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
env->Global()->Set(v8::String::NewFromUtf8(isolate, "instance"),
instance);
v8::Script::Compile(v8::String::NewFromUtf8(
env->GetIsolate(), native_method_test_source))->Run();
isolate, native_method_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
env->Global()->Get(v8::String::NewFromUtf8(isolate, "start")));
{
// Make sure method ICs are in monomorphic state before starting
// profiling.
@ -903,10 +911,10 @@ TEST(NativeMethodMonomorphicIC) {
RunProfiler(env, function, args, ARRAY_SIZE(args), 100);
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
GetChild(env->GetIsolate(), root, "start");
GetChild(isolate, root, "start");
const v8::CpuProfileNode* startNode =
GetChild(env->GetIsolate(), root, "start");
GetChild(env->GetIsolate(), startNode, "fooMethod");
GetChild(isolate, root, "start");
GetChild(isolate, startNode, "fooMethod");
const_cast<v8::CpuProfile*>(profile)->Delete();
}
@ -1171,7 +1179,7 @@ TEST(JsNativeJsSample) {
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
CallJsFunction);
env->GetIsolate(), CallJsFunction);
v8::Local<v8::Function> func = func_template->GetFunction();
func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
env->Global()->Set(
@ -1254,7 +1262,7 @@ TEST(JsNativeJsRuntimeJsSample) {
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
CallJsFunction);
env->GetIsolate(), CallJsFunction);
v8::Local<v8::Function> func = func_template->GetFunction();
func->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction"));
env->Global()->Set(
@ -1341,14 +1349,14 @@ TEST(JsNative1JsNative2JsSample) {
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
CallJsFunction);
env->GetIsolate(), CallJsFunction);
v8::Local<v8::Function> func1 = func_template->GetFunction();
func1->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"));
env->Global()->Set(
v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction1"), func1);
v8::Local<v8::Function> func2 = v8::FunctionTemplate::New(
CallJsFunction2)->GetFunction();
env->GetIsolate(), CallJsFunction2)->GetFunction();
func2->SetName(v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"));
env->Global()->Set(
v8::String::NewFromUtf8(env->GetIsolate(), "CallJsFunction2"), func2);

View File

@ -4476,33 +4476,34 @@ TEST(InterceptorPropertyMirror) {
TEST(HiddenPrototypePropertyMirror) {
// Create a V8 environment with debug access.
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
env.ExposeDebug();
v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "x"),
v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "x"),
v8::Number::New(0));
v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->SetHiddenPrototype(true);
t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "y"),
t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "y"),
v8::Number::New(1));
v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
v8::Handle<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(isolate);
t2->SetHiddenPrototype(true);
t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "z"),
t2->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "z"),
v8::Number::New(2));
v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "u"),
v8::Handle<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(isolate);
t3->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "u"),
v8::Number::New(3));
// Create object and set them on the global object.
v8::Handle<v8::Object> o0 = t0->GetFunction()->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o0"), o0);
env->Global()->Set(v8::String::NewFromUtf8(isolate, "o0"), o0);
v8::Handle<v8::Object> o1 = t1->GetFunction()->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o1"), o1);
env->Global()->Set(v8::String::NewFromUtf8(isolate, "o1"), o1);
v8::Handle<v8::Object> o2 = t2->GetFunction()->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o2"), o2);
env->Global()->Set(v8::String::NewFromUtf8(isolate, "o2"), o2);
v8::Handle<v8::Object> o3 = t3->GetFunction()->NewInstance();
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "o3"), o3);
env->Global()->Set(v8::String::NewFromUtf8(isolate, "o3"), o3);
// Get mirrors for the four objects.
CompileRun(
@ -4527,7 +4528,7 @@ TEST(HiddenPrototypePropertyMirror) {
// Set o1 as prototype for o0. o1 has the hidden prototype flag so all
// properties on o1 should be seen on o0.
o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o1);
o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o1);
CHECK_EQ(2, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(0, CompileRun(
@ -4538,7 +4539,7 @@ TEST(HiddenPrototypePropertyMirror) {
// Set o2 as prototype for o0 (it will end up after o1 as o1 has the hidden
// prototype flag. o2 also has the hidden prototype flag so all properties
// on o2 should be seen on o0 as well as properties on o1.
o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o2);
o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o2);
CHECK_EQ(3, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(0, CompileRun(
@ -4554,7 +4555,7 @@ TEST(HiddenPrototypePropertyMirror) {
// from o1 and o2 should still be seen on o0.
// Final prototype chain: o0 -> o1 -> o2 -> o3
// Hidden prototypes: ^^ ^^
o0->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), o3);
o0->Set(v8::String::NewFromUtf8(isolate, "__proto__"), o3);
CHECK_EQ(3, CompileRun(
"o0_mirror.propertyNames().length")->Int32Value());
CHECK_EQ(1, CompileRun(
@ -4657,18 +4658,19 @@ TEST(NativeGetterThrowingErrorPropertyMirror) {
TEST(NoHiddenProperties) {
// Create a V8 environment with debug access.
DebugLocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
env.ExposeDebug();
// Create an object in the global scope.
const char* source = "var obj = {a: 1};";
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), source))
v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))
->Run();
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "obj")));
env->Global()->Get(v8::String::NewFromUtf8(isolate, "obj")));
// Set a hidden property on the object.
obj->SetHiddenValue(
v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::a"),
v8::String::NewFromUtf8(isolate, "v8::test-debug::a"),
v8::Int32::New(11));
// Get mirror for the object with property getter.
@ -4685,34 +4687,34 @@ TEST(NoHiddenProperties) {
"obj_mirror.property('a').value().value() == 1")->BooleanValue());
// Object created by t0 will become hidden prototype of object 'obj'.
v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "b"),
v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
t0->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "b"),
v8::Number::New(2));
t0->SetHiddenPrototype(true);
v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "c"),
v8::Handle<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
t1->InstanceTemplate()->Set(v8::String::NewFromUtf8(isolate, "c"),
v8::Number::New(3));
// Create proto objects, add hidden properties to them and set them on
// the global object.
v8::Handle<v8::Object> protoObj = t0->GetFunction()->NewInstance();
protoObj->SetHiddenValue(
v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::b"),
v8::String::NewFromUtf8(isolate, "v8::test-debug::b"),
v8::Int32::New(12));
env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "protoObj"),
env->Global()->Set(v8::String::NewFromUtf8(isolate, "protoObj"),
protoObj);
v8::Handle<v8::Object> grandProtoObj = t1->GetFunction()->NewInstance();
grandProtoObj->SetHiddenValue(
v8::String::NewFromUtf8(env->GetIsolate(), "v8::test-debug::c"),
v8::String::NewFromUtf8(isolate, "v8::test-debug::c"),
v8::Int32::New(13));
env->Global()->Set(
v8::String::NewFromUtf8(env->GetIsolate(), "grandProtoObj"),
v8::String::NewFromUtf8(isolate, "grandProtoObj"),
grandProtoObj);
// Setting prototypes: obj->protoObj->grandProtoObj
protoObj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"),
protoObj->Set(v8::String::NewFromUtf8(isolate, "__proto__"),
grandProtoObj);
obj->Set(v8::String::NewFromUtf8(env->GetIsolate(), "__proto__"), protoObj);
obj->Set(v8::String::NewFromUtf8(isolate, "__proto__"), protoObj);
// Get mirror for the object with property getter.
CompileRun("var obj_mirror = debug.MakeMirror(obj);");
@ -5207,7 +5209,7 @@ void V8Thread::Run() {
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(
v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"),
v8::FunctionTemplate::New(ThreadedAtBarrier1));
v8::FunctionTemplate::New(CcTest::isolate(), ThreadedAtBarrier1));
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(),
NULL,
global_template);
@ -5568,16 +5570,16 @@ TEST(CallFunctionInDebugger) {
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckFrameCount"),
v8::FunctionTemplate::New(CheckFrameCount));
v8::FunctionTemplate::New(CcTest::isolate(), CheckFrameCount));
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckSourceLine"),
v8::FunctionTemplate::New(CheckSourceLine));
v8::FunctionTemplate::New(CcTest::isolate(), CheckSourceLine));
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckDataParameter"),
v8::FunctionTemplate::New(CheckDataParameter));
v8::FunctionTemplate::New(CcTest::isolate(), CheckDataParameter));
global_template->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "CheckClosure"),
v8::FunctionTemplate::New(CheckClosure));
v8::FunctionTemplate::New(CcTest::isolate(), CheckClosure));
v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate(),
NULL,
global_template);
@ -7427,7 +7429,7 @@ TEST(DebugBreakStackInspection) {
CompileFunction(&env, frame_local_value_source, "frame_local_value");
v8::Handle<v8::FunctionTemplate> schedule_break_template =
v8::FunctionTemplate::New(ScheduleBreak);
v8::FunctionTemplate::New(env->GetIsolate(), ScheduleBreak);
v8::Handle<v8::Function> schedule_break =
schedule_break_template->GetFunction();
env->Global()->Set(v8_str("scheduleBreak"), schedule_break);

View File

@ -95,7 +95,8 @@ static v8::Local<v8::ObjectTemplate> CreateConstructor(
const char* descriptor_name = NULL,
v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
v8::Handle<v8::DeclaredAccessorDescriptor>()) {
v8::Local<v8::FunctionTemplate> constructor = v8::FunctionTemplate::New();
v8::Local<v8::FunctionTemplate> constructor =
v8::FunctionTemplate::New(context->GetIsolate());
v8::Local<v8::ObjectTemplate> obj_template = constructor->InstanceTemplate();
// Setup object template.
if (descriptor_name != NULL && !descriptor.IsEmpty()) {

View File

@ -118,7 +118,7 @@ void DeclarationContext::InitializeIfNeeded() {
if (is_initialized_) return;
Isolate* isolate = CcTest::isolate();
HandleScope scope(isolate);
Local<FunctionTemplate> function = FunctionTemplate::New();
Local<FunctionTemplate> function = FunctionTemplate::New(isolate);
Local<Value> data = External::New(CcTest::isolate(), this);
GetHolder(function)->SetNamedPropertyHandler(&HandleGet,
&HandleSet,
@ -634,7 +634,7 @@ TEST(AbsentInPrototype) {
class ExistsInHiddenPrototypeContext: public DeclarationContext {
public:
ExistsInHiddenPrototypeContext() {
hidden_proto_ = FunctionTemplate::New();
hidden_proto_ = FunctionTemplate::New(CcTest::isolate());
hidden_proto_->SetHiddenPrototype(true);
}

View File

@ -2087,6 +2087,7 @@ HeapProfilerExtension::GetNativeFunctionTemplate(v8::Isolate* isolate,
v8::Handle<v8::String> name) {
if (name->Equals(v8::String::NewFromUtf8(isolate, "findUntrackedObjects"))) {
return v8::FunctionTemplate::New(
isolate,
HeapProfilerExtension::FindUntrackedObjects);
} else {
CHECK(false);

View File

@ -115,14 +115,14 @@ const char* TraceExtension::kSource =
v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<String> name) {
if (name->Equals(String::NewFromUtf8(isolate, "trace"))) {
return v8::FunctionTemplate::New(TraceExtension::Trace);
return v8::FunctionTemplate::New(isolate, TraceExtension::Trace);
} else if (name->Equals(
String::NewFromUtf8(isolate, "js_trace"))) {
return v8::FunctionTemplate::New(TraceExtension::JSTrace);
return v8::FunctionTemplate::New(isolate, TraceExtension::JSTrace);
} else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp"))) {
return v8::FunctionTemplate::New(TraceExtension::JSEntrySP);
return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySP);
} else if (name->Equals(String::NewFromUtf8(isolate, "js_entry_sp_level2"))) {
return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2);
return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySPLevel2);
} else {
CHECK(false);
return v8::Handle<v8::FunctionTemplate>();
@ -232,7 +232,7 @@ static void construct_call(const v8::FunctionCallbackInfo<v8::Value>& args) {
void CreateFramePointerGrabberConstructor(v8::Local<v8::Context> context,
const char* constructor_name) {
Local<v8::FunctionTemplate> constructor_template =
v8::FunctionTemplate::New(construct_call);
v8::FunctionTemplate::New(context->GetIsolate(), construct_call);
constructor_template->SetClassName(v8_str("FPGrabber"));
Local<Function> fun = constructor_template->GetFunction();
context->Global()->Set(v8_str(constructor_name), fun);

View File

@ -329,18 +329,20 @@ static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(LogCallbacks) {
v8::Isolate* isolate = CcTest::isolate();
ScopedLoggerInitializer initialize_logger;
Logger* logger = initialize_logger.logger();
v8::Local<v8::FunctionTemplate> obj =
v8::Local<v8::FunctionTemplate>::New(CcTest::isolate(),
v8::FunctionTemplate::New());
v8::Local<v8::FunctionTemplate>::New(isolate,
v8::FunctionTemplate::New(isolate));
obj->SetClassName(v8_str("Obj"));
v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
v8::Local<v8::Signature> signature =
v8::Signature::New(CcTest::isolate(), obj);
v8::Signature::New(isolate, obj);
proto->Set(v8_str("method1"),
v8::FunctionTemplate::New(ObjMethod1,
v8::FunctionTemplate::New(isolate,
ObjMethod1,
v8::Handle<v8::Value>(),
signature),
static_cast<v8::PropertyAttribute>(v8::DontDelete));
@ -379,12 +381,13 @@ static void Prop2Getter(v8::Local<v8::String> property,
TEST(LogAccessorCallbacks) {
v8::Isolate* isolate = CcTest::isolate();
ScopedLoggerInitializer initialize_logger;
Logger* logger = initialize_logger.logger();
v8::Local<v8::FunctionTemplate> obj =
v8::Local<v8::FunctionTemplate>::New(CcTest::isolate(),
v8::FunctionTemplate::New());
v8::Local<v8::FunctionTemplate>::New(isolate,
v8::FunctionTemplate::New(isolate));
obj->SetClassName(v8_str("Obj"));
v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);

View File

@ -379,7 +379,7 @@ TEST(HiddenPrototypeObservation) {
HarmonyIsolate isolate;
HandleScope scope(isolate.GetIsolate());
LocalContext context(isolate.GetIsolate());
Handle<FunctionTemplate> tmpl = FunctionTemplate::New();
Handle<FunctionTemplate> tmpl = FunctionTemplate::New(isolate.GetIsolate());
tmpl->SetHiddenPrototype(true);
tmpl->InstanceTemplate()->Set(
String::NewFromUtf8(isolate.GetIsolate(), "foo"), Number::New(75));

View File

@ -74,7 +74,7 @@ TEST(StackAlignment) {
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->Set(v8_str("get_stack_pointer"),
v8::FunctionTemplate::New(GetStackPointer));
v8::FunctionTemplate::New(isolate, GetStackPointer));
LocalContext env(NULL, global_template);
CompileRun(

View File

@ -107,13 +107,13 @@ v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
v8::FunctionCallback doloop) {
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::NewFromUtf8(isolate, "terminate"),
v8::FunctionTemplate::New(terminate));
v8::FunctionTemplate::New(isolate, terminate));
global->Set(v8::String::NewFromUtf8(isolate, "fail"),
v8::FunctionTemplate::New(Fail));
v8::FunctionTemplate::New(isolate, Fail));
global->Set(v8::String::NewFromUtf8(isolate, "loop"),
v8::FunctionTemplate::New(Loop));
v8::FunctionTemplate::New(isolate, Loop));
global->Set(v8::String::NewFromUtf8(isolate, "doloop"),
v8::FunctionTemplate::New(doloop));
v8::FunctionTemplate::New(isolate, doloop));
return global;
}
@ -242,27 +242,28 @@ void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
// Test that we correctly handle termination exceptions if they are
// triggered by the creation of error objects in connection with ICs.
TEST(TerminateLoadICException) {
v8::HandleScope scope(CcTest::isolate());
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(
v8::String::NewFromUtf8(CcTest::isolate(), "terminate_or_return_object"),
v8::FunctionTemplate::New(TerminateOrReturnObject));
global->Set(v8::String::NewFromUtf8(CcTest::isolate(), "fail"),
v8::FunctionTemplate::New(Fail));
global->Set(v8::String::NewFromUtf8(CcTest::isolate(), "loop"),
v8::FunctionTemplate::New(LoopGetProperty));
v8::String::NewFromUtf8(isolate, "terminate_or_return_object"),
v8::FunctionTemplate::New(isolate, TerminateOrReturnObject));
global->Set(v8::String::NewFromUtf8(isolate, "fail"),
v8::FunctionTemplate::New(isolate, Fail));
global->Set(v8::String::NewFromUtf8(isolate, "loop"),
v8::FunctionTemplate::New(isolate, LoopGetProperty));
v8::Handle<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
CHECK(!v8::V8::IsExecutionTerminating(isolate));
// Run a loop that will be infinite if thread termination does not work.
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
isolate, "try { loop(); fail(); } catch(e) { fail(); }");
call_count = 0;
v8::Script::Compile(source)->Run();
// Test that we can run the code again after thread termination.
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
CHECK(!v8::V8::IsExecutionTerminating(isolate));
call_count = 0;
v8::Script::Compile(source)->Run();
}
@ -299,20 +300,21 @@ void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
// Test that reentry into V8 while the termination exception is still pending
// (has not yet unwound the 0-level JS frame) does not crash.
TEST(TerminateAndReenterFromThreadItself) {
v8::HandleScope scope(CcTest::isolate());
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(
CcTest::isolate(), TerminateCurrentThread, ReenterAfterTermination);
isolate, TerminateCurrentThread, ReenterAfterTermination);
v8::Handle<v8::Context> context =
v8::Context::New(CcTest::isolate(), NULL, global);
v8::Context::New(isolate, NULL, global);
v8::Context::Scope context_scope(context);
CHECK(!v8::V8::IsExecutionTerminating());
v8::Handle<v8::String> source = v8::String::NewFromUtf8(
CcTest::isolate(), "try { loop(); fail(); } catch(e) { fail(); }");
isolate, "try { loop(); fail(); } catch(e) { fail(); }");
v8::Script::Compile(source)->Run();
CHECK(!v8::V8::IsExecutionTerminating(CcTest::isolate()));
CHECK(!v8::V8::IsExecutionTerminating(isolate));
// Check we can run JS again after termination.
CHECK(v8::Script::Compile(
v8::String::NewFromUtf8(CcTest::isolate(),
v8::String::NewFromUtf8(isolate,
"function f() { return true; }"
"f()"))
->Run()