Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: test/cctest/test-api.cc

Issue 104183002: Remove internal uses of HandleScope::Close(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 void FastReturnValueCallback<Object>( 1188 void FastReturnValueCallback<Object>(
1189 const v8::FunctionCallbackInfo<v8::Value>& info) { 1189 const v8::FunctionCallbackInfo<v8::Value>& info) {
1190 v8::Handle<v8::Object> object; 1190 v8::Handle<v8::Object> object;
1191 if (!fast_return_value_object_is_empty) object = Object::New(); 1191 if (!fast_return_value_object_is_empty) object = Object::New();
1192 info.GetReturnValue().Set(object); 1192 info.GetReturnValue().Set(object);
1193 } 1193 }
1194 1194
1195 template<typename T> 1195 template<typename T>
1196 Handle<Value> TestFastReturnValues() { 1196 Handle<Value> TestFastReturnValues() {
1197 LocalContext env; 1197 LocalContext env;
1198 v8::HandleScope scope(env->GetIsolate()); 1198 v8::EscapableHandleScope scope(env->GetIsolate());
1199 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); 1199 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
1200 v8::FunctionCallback callback = &FastReturnValueCallback<T>; 1200 v8::FunctionCallback callback = &FastReturnValueCallback<T>;
1201 object_template->Set(env->GetIsolate(), "callback", 1201 object_template->Set(env->GetIsolate(), "callback",
1202 v8::FunctionTemplate::New(callback)); 1202 v8::FunctionTemplate::New(callback));
1203 v8::Local<v8::Object> object = object_template->NewInstance(); 1203 v8::Local<v8::Object> object = object_template->NewInstance();
1204 (*env)->Global()->Set(v8_str("callback_object"), object); 1204 (*env)->Global()->Set(v8_str("callback_object"), object);
1205 return scope.Close(CompileRun("callback_object.callback()")); 1205 return scope.Escape(CompileRun("callback_object.callback()"));
1206 } 1206 }
1207 1207
1208 1208
1209 THREADED_PROFILED_TEST(FastReturnValues) { 1209 THREADED_PROFILED_TEST(FastReturnValues) {
1210 LocalContext env; 1210 LocalContext env;
1211 v8::HandleScope scope(CcTest::isolate()); 1211 v8::HandleScope scope(CcTest::isolate());
1212 v8::Handle<v8::Value> value; 1212 v8::Handle<v8::Value> value;
1213 // check int32_t and uint32_t 1213 // check int32_t and uint32_t
1214 int32_t int_values[] = { 1214 int32_t int_values[] = {
1215 0, 234, -723, 1215 0, 234, -723,
(...skipping 2965 matching lines...) Expand 10 before | Expand all | Expand 10 after
4181 CHECK_EQ(2, arr->Get(1)->Int32Value()); 4181 CHECK_EQ(2, arr->Get(1)->Int32Value());
4182 CHECK_EQ(3, arr->Get(2)->Int32Value()); 4182 CHECK_EQ(3, arr->Get(2)->Int32Value());
4183 array = v8::Array::New(context->GetIsolate(), 27); 4183 array = v8::Array::New(context->GetIsolate(), 27);
4184 CHECK_EQ(27, array->Length()); 4184 CHECK_EQ(27, array->Length());
4185 array = v8::Array::New(context->GetIsolate(), -27); 4185 array = v8::Array::New(context->GetIsolate(), -27);
4186 CHECK_EQ(0, array->Length()); 4186 CHECK_EQ(0, array->Length());
4187 } 4187 }
4188 4188
4189 4189
4190 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) { 4190 void HandleF(const v8::FunctionCallbackInfo<v8::Value>& args) {
4191 v8::HandleScope scope(args.GetIsolate()); 4191 v8::EscapableHandleScope scope(args.GetIsolate());
4192 ApiTestFuzzer::Fuzz(); 4192 ApiTestFuzzer::Fuzz();
4193 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length()); 4193 Local<v8::Array> result = v8::Array::New(args.GetIsolate(), args.Length());
4194 for (int i = 0; i < args.Length(); i++) 4194 for (int i = 0; i < args.Length(); i++)
4195 result->Set(i, args[i]); 4195 result->Set(i, args[i]);
4196 args.GetReturnValue().Set(scope.Close(result)); 4196 args.GetReturnValue().Set(scope.Escape(result));
4197 } 4197 }
4198 4198
4199 4199
4200 THREADED_TEST(Vector) { 4200 THREADED_TEST(Vector) {
4201 v8::HandleScope scope(CcTest::isolate()); 4201 v8::HandleScope scope(CcTest::isolate());
4202 Local<ObjectTemplate> global = ObjectTemplate::New(); 4202 Local<ObjectTemplate> global = ObjectTemplate::New();
4203 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); 4203 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF));
4204 LocalContext context(0, global); 4204 LocalContext context(0, global);
4205 4205
4206 const char* fun = "f()"; 4206 const char* fun = "f()";
(...skipping 9022 matching lines...) Expand 10 before | Expand all | Expand 10 after
13229 } 13229 }
13230 { v8::HandleScope scope(CcTest::isolate()); 13230 { v8::HandleScope scope(CcTest::isolate());
13231 LocalContext context; 13231 LocalContext context;
13232 CompileRun(source); 13232 CompileRun(source);
13233 } 13233 }
13234 } 13234 }
13235 } 13235 }
13236 13236
13237 13237
13238 static v8::Handle<Value> NestedScope(v8::Local<Context> env) { 13238 static v8::Handle<Value> NestedScope(v8::Local<Context> env) {
13239 v8::HandleScope inner(env->GetIsolate()); 13239 v8::EscapableHandleScope inner(env->GetIsolate());
13240 env->Enter(); 13240 env->Enter();
13241 v8::Handle<Value> three = v8_num(3); 13241 v8::Local<Value> three = v8_num(3);
13242 v8::Handle<Value> value = inner.Close(three); 13242 v8::Local<Value> value = inner.Escape(three);
13243 env->Exit(); 13243 env->Exit();
13244 return value; 13244 return value;
13245 } 13245 }
13246 13246
13247 13247
13248 THREADED_TEST(NestedHandleScopeAndContexts) { 13248 THREADED_TEST(NestedHandleScopeAndContexts) {
13249 v8::Isolate* isolate = CcTest::isolate(); 13249 v8::Isolate* isolate = CcTest::isolate();
13250 v8::HandleScope outer(isolate); 13250 v8::HandleScope outer(isolate);
13251 v8::Local<Context> env = Context::New(isolate); 13251 v8::Local<Context> env = Context::New(isolate);
13252 env->Enter(); 13252 env->Enter();
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
13858 13858
13859 // Regression test for issue 54, object templates with internal fields 13859 // Regression test for issue 54, object templates with internal fields
13860 // but no accessors or interceptors did not get their internal field 13860 // but no accessors or interceptors did not get their internal field
13861 // count set on instances. 13861 // count set on instances.
13862 THREADED_TEST(Regress54) { 13862 THREADED_TEST(Regress54) {
13863 LocalContext context; 13863 LocalContext context;
13864 v8::Isolate* isolate = context->GetIsolate(); 13864 v8::Isolate* isolate = context->GetIsolate();
13865 v8::HandleScope outer(isolate); 13865 v8::HandleScope outer(isolate);
13866 static v8::Persistent<v8::ObjectTemplate> templ; 13866 static v8::Persistent<v8::ObjectTemplate> templ;
13867 if (templ.IsEmpty()) { 13867 if (templ.IsEmpty()) {
13868 v8::HandleScope inner(isolate); 13868 v8::EscapableHandleScope inner(isolate);
13869 v8::Handle<v8::ObjectTemplate> local = v8::ObjectTemplate::New(); 13869 v8::Local<v8::ObjectTemplate> local = v8::ObjectTemplate::New();
13870 local->SetInternalFieldCount(1); 13870 local->SetInternalFieldCount(1);
13871 templ.Reset(isolate, inner.Close(local)); 13871 templ.Reset(isolate, inner.Escape(local));
13872 } 13872 }
13873 v8::Handle<v8::Object> result = 13873 v8::Handle<v8::Object> result =
13874 v8::Local<v8::ObjectTemplate>::New(isolate, templ)->NewInstance(); 13874 v8::Local<v8::ObjectTemplate>::New(isolate, templ)->NewInstance();
13875 CHECK_EQ(1, result->InternalFieldCount()); 13875 CHECK_EQ(1, result->InternalFieldCount());
13876 } 13876 }
13877 13877
13878 13878
13879 // If part of the threaded tests, this test makes ThreadingTest fail 13879 // If part of the threaded tests, this test makes ThreadingTest fail
13880 // on mac. 13880 // on mac.
13881 TEST(CatchStackOverflow) { 13881 TEST(CatchStackOverflow) {
(...skipping 6990 matching lines...) Expand 10 before | Expand all | Expand 10 after
20872 } 20872 }
20873 for (int i = 0; i < runs; i++) { 20873 for (int i = 0; i < runs; i++) {
20874 Local<String> expected; 20874 Local<String> expected;
20875 if (i != 0) { 20875 if (i != 0) {
20876 CHECK_EQ(v8_str("escape value"), values[i]); 20876 CHECK_EQ(v8_str("escape value"), values[i]);
20877 } else { 20877 } else {
20878 CHECK(values[i].IsEmpty()); 20878 CHECK(values[i].IsEmpty());
20879 } 20879 }
20880 } 20880 }
20881 } 20881 }
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698