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

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

Issue 725293003: don't use to-be-deprecated Value::To* without isolate parameter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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
« no previous file with comments | « test/cctest/test-log.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 939
940 Handle<JSFunction> copy_fun = 940 Handle<JSFunction> copy_fun =
941 isolate->factory()->NewFunctionFromSharedFunctionInfo( 941 isolate->factory()->NewFunctionFromSharedFunctionInfo(
942 copy, isolate->native_context()); 942 copy, isolate->native_context());
943 943
944 USE(Execution::Call(isolate, copy_fun, global, 0, NULL)); 944 USE(Execution::Call(isolate, copy_fun, global, 0, NULL));
945 945
946 CHECK_EQ(600000 + 700000, CompileRun("(a + b).length")->Int32Value()); 946 CHECK_EQ(600000 + 700000, CompileRun("(a + b).length")->Int32Value());
947 CHECK_EQ(500000 + 600000, CompileRun("(b + c).length")->Int32Value()); 947 CHECK_EQ(500000 + 600000, CompileRun("(b + c).length")->Int32Value());
948 Heap* heap = isolate->heap(); 948 Heap* heap = isolate->heap();
949 CHECK(heap->InSpace(*v8::Utils::OpenHandle(*CompileRun("a")->ToString()), 949 CHECK(heap->InSpace(
950 OLD_DATA_SPACE)); 950 *v8::Utils::OpenHandle(*CompileRun("a")->ToString(CcTest::isolate())),
951 CHECK(heap->InSpace(*v8::Utils::OpenHandle(*CompileRun("b")->ToString()), 951 OLD_DATA_SPACE));
952 OLD_DATA_SPACE)); 952 CHECK(heap->InSpace(
953 CHECK(heap->InSpace(*v8::Utils::OpenHandle(*CompileRun("c")->ToString()), 953 *v8::Utils::OpenHandle(*CompileRun("b")->ToString(CcTest::isolate())),
954 OLD_DATA_SPACE)); 954 OLD_DATA_SPACE));
955 CHECK(heap->InSpace(
956 *v8::Utils::OpenHandle(*CompileRun("c")->ToString(CcTest::isolate())),
957 OLD_DATA_SPACE));
955 958
956 delete cache; 959 delete cache;
957 source_a.Dispose(); 960 source_a.Dispose();
958 source_b.Dispose(); 961 source_b.Dispose();
959 source_c.Dispose(); 962 source_c.Dispose();
960 } 963 }
961 964
962 965
963 class SerializerOneByteResource 966 class SerializerOneByteResource
964 : public v8::String::ExternalOneByteStringResource { 967 : public v8::String::ExternalOneByteStringResource {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); 1204 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
1202 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); 1205 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
1203 CHECK(data); 1206 CHECK(data);
1204 // Persist cached data. 1207 // Persist cached data.
1205 uint8_t* buffer = NewArray<uint8_t>(data->length); 1208 uint8_t* buffer = NewArray<uint8_t>(data->length);
1206 MemCopy(buffer, data->data, data->length); 1209 MemCopy(buffer, data->data, data->length);
1207 cache = new v8::ScriptCompiler::CachedData( 1210 cache = new v8::ScriptCompiler::CachedData(
1208 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); 1211 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
1209 1212
1210 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1213 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1211 CHECK(result->ToString()->Equals(v8_str("abcdef"))); 1214 CHECK(result->ToString(isolate1)->Equals(v8_str("abcdef")));
1212 } 1215 }
1213 isolate1->Dispose(); 1216 isolate1->Dispose();
1214 1217
1215 v8::Isolate* isolate2 = v8::Isolate::New(); 1218 v8::Isolate* isolate2 = v8::Isolate::New();
1216 isolate2->SetJitCodeEventHandler(v8::kJitCodeEventDefault, 1219 isolate2->SetJitCodeEventHandler(v8::kJitCodeEventDefault,
1217 SerializerCodeEventListener); 1220 SerializerCodeEventListener);
1218 toplevel_test_code_event_found = false; 1221 toplevel_test_code_event_found = false;
1219 { 1222 {
1220 v8::Isolate::Scope iscope(isolate2); 1223 v8::Isolate::Scope iscope(isolate2);
1221 v8::HandleScope scope(isolate2); 1224 v8::HandleScope scope(isolate2);
1222 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1225 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1223 v8::Context::Scope context_scope(context); 1226 v8::Context::Scope context_scope(context);
1224 1227
1225 v8::Local<v8::String> source_str = v8_str(source); 1228 v8::Local<v8::String> source_str = v8_str(source);
1226 v8::ScriptOrigin origin(v8_str("test")); 1229 v8::ScriptOrigin origin(v8_str("test"));
1227 v8::ScriptCompiler::Source source(source_str, origin, cache); 1230 v8::ScriptCompiler::Source source(source_str, origin, cache);
1228 v8::Local<v8::UnboundScript> script; 1231 v8::Local<v8::UnboundScript> script;
1229 { 1232 {
1230 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1233 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1231 script = v8::ScriptCompiler::CompileUnbound( 1234 script = v8::ScriptCompiler::CompileUnbound(
1232 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1235 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
1233 } 1236 }
1234 CHECK(!cache->rejected); 1237 CHECK(!cache->rejected);
1235 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1238 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1236 CHECK(result->ToString()->Equals(v8_str("abcdef"))); 1239 CHECK(result->ToString(isolate2)->Equals(v8_str("abcdef")));
1237 } 1240 }
1238 DCHECK(toplevel_test_code_event_found); 1241 DCHECK(toplevel_test_code_event_found);
1239 isolate2->Dispose(); 1242 isolate2->Dispose();
1240 } 1243 }
1241 1244
1242 1245
1243 TEST(SerializeWithHarmonyScoping) { 1246 TEST(SerializeWithHarmonyScoping) {
1244 FLAG_serialize_toplevel = true; 1247 FLAG_serialize_toplevel = true;
1245 FLAG_harmony_scoping = true; 1248 FLAG_harmony_scoping = true;
1246 1249
(...skipping 20 matching lines...) Expand all
1267 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); 1270 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
1268 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); 1271 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
1269 CHECK(data); 1272 CHECK(data);
1270 // Persist cached data. 1273 // Persist cached data.
1271 uint8_t* buffer = NewArray<uint8_t>(data->length); 1274 uint8_t* buffer = NewArray<uint8_t>(data->length);
1272 MemCopy(buffer, data->data, data->length); 1275 MemCopy(buffer, data->data, data->length);
1273 cache = new v8::ScriptCompiler::CachedData( 1276 cache = new v8::ScriptCompiler::CachedData(
1274 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); 1277 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
1275 1278
1276 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1279 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1277 CHECK(result->ToString()->Equals(v8_str("XY"))); 1280 CHECK(result->ToString(isolate1)->Equals(v8_str("XY")));
1278 } 1281 }
1279 isolate1->Dispose(); 1282 isolate1->Dispose();
1280 1283
1281 v8::Isolate* isolate2 = v8::Isolate::New(); 1284 v8::Isolate* isolate2 = v8::Isolate::New();
1282 { 1285 {
1283 v8::Isolate::Scope iscope(isolate2); 1286 v8::Isolate::Scope iscope(isolate2);
1284 v8::HandleScope scope(isolate2); 1287 v8::HandleScope scope(isolate2);
1285 v8::Local<v8::Context> context = v8::Context::New(isolate2); 1288 v8::Local<v8::Context> context = v8::Context::New(isolate2);
1286 v8::Context::Scope context_scope(context); 1289 v8::Context::Scope context_scope(context);
1287 1290
1288 // Reverse order of prior running scripts. 1291 // Reverse order of prior running scripts.
1289 CompileRun(source2); 1292 CompileRun(source2);
1290 CompileRun(source1); 1293 CompileRun(source1);
1291 1294
1292 v8::Local<v8::String> source_str = v8_str(source3); 1295 v8::Local<v8::String> source_str = v8_str(source3);
1293 v8::ScriptOrigin origin(v8_str("test")); 1296 v8::ScriptOrigin origin(v8_str("test"));
1294 v8::ScriptCompiler::Source source(source_str, origin, cache); 1297 v8::ScriptCompiler::Source source(source_str, origin, cache);
1295 v8::Local<v8::UnboundScript> script; 1298 v8::Local<v8::UnboundScript> script;
1296 { 1299 {
1297 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1300 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1298 script = v8::ScriptCompiler::CompileUnbound( 1301 script = v8::ScriptCompiler::CompileUnbound(
1299 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1302 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
1300 } 1303 }
1301 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1304 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1302 CHECK(result->ToString()->Equals(v8_str("XY"))); 1305 CHECK(result->ToString(isolate2)->Equals(v8_str("XY")));
1303 } 1306 }
1304 isolate2->Dispose(); 1307 isolate2->Dispose();
1305 } 1308 }
OLDNEW
« no previous file with comments | « test/cctest/test-log.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698