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

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

Issue 469783002: Require V8 to be explicitly initialized before an Isolate is created (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 3 months 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 | « test/cctest/test-regexp.cc ('k') | test/cctest/test-spaces.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 27 matching lines...) Expand all
38 #include "src/natives.h" 38 #include "src/natives.h"
39 #include "src/objects.h" 39 #include "src/objects.h"
40 #include "src/runtime.h" 40 #include "src/runtime.h"
41 #include "src/scopeinfo.h" 41 #include "src/scopeinfo.h"
42 #include "src/serialize.h" 42 #include "src/serialize.h"
43 #include "src/snapshot.h" 43 #include "src/snapshot.h"
44 #include "test/cctest/cctest.h" 44 #include "test/cctest/cctest.h"
45 45
46 using namespace v8::internal; 46 using namespace v8::internal;
47 47
48 static const unsigned kCounters = 256;
49 static int local_counters[kCounters];
50 static const char* local_counter_names[kCounters];
51
52
53 static unsigned CounterHash(const char* s) {
54 unsigned hash = 0;
55 while (*++s) {
56 hash |= hash << 5;
57 hash += *s;
58 }
59 return hash;
60 }
61
62
63 // Callback receiver to track counters in test.
64 static int* counter_function(const char* name) {
65 unsigned hash = CounterHash(name) % kCounters;
66 unsigned original_hash = hash;
67 USE(original_hash);
68 while (true) {
69 if (local_counter_names[hash] == name) {
70 return &local_counters[hash];
71 }
72 if (local_counter_names[hash] == 0) {
73 local_counter_names[hash] = name;
74 return &local_counters[hash];
75 }
76 if (strcmp(local_counter_names[hash], name) == 0) {
77 return &local_counters[hash];
78 }
79 hash = (hash + 1) % kCounters;
80 DCHECK(hash != original_hash); // Hash table has been filled up.
81 }
82 }
83
84 48
85 template <class T> 49 template <class T>
86 static Address AddressOf(T id) { 50 static Address AddressOf(T id) {
87 return ExternalReference(id, CcTest::i_isolate()).address(); 51 return ExternalReference(id, CcTest::i_isolate()).address();
88 } 52 }
89 53
90 54
91 template <class T> 55 template <class T>
92 static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) { 56 static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) {
93 return encoder.Encode(AddressOf(id)); 57 return encoder.Encode(AddressOf(id));
94 } 58 }
95 59
96 60
97 static int make_code(TypeCode type, int id) { 61 static int make_code(TypeCode type, int id) {
98 return static_cast<uint32_t>(type) << kReferenceTypeShift | id; 62 return static_cast<uint32_t>(type) << kReferenceTypeShift | id;
99 } 63 }
100 64
101 65
102 TEST(ExternalReferenceEncoder) { 66 TEST(ExternalReferenceEncoder) {
103 Isolate* isolate = CcTest::i_isolate(); 67 Isolate* isolate = CcTest::i_isolate();
104 isolate->stats_table()->SetCounterFunction(counter_function);
105 v8::V8::Initialize(); 68 v8::V8::Initialize();
106 69
107 ExternalReferenceEncoder encoder(isolate); 70 ExternalReferenceEncoder encoder(isolate);
108 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), 71 CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode),
109 Encode(encoder, Builtins::kArrayCode)); 72 Encode(encoder, Builtins::kArrayCode));
110 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), 73 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort),
111 Encode(encoder, Runtime::kAbort)); 74 Encode(encoder, Runtime::kAbort));
112 ExternalReference total_compile_size =
113 ExternalReference(isolate->counters()->total_compile_size());
114 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_total_compile_size),
115 encoder.Encode(total_compile_size.address()));
116 ExternalReference stack_limit_address = 75 ExternalReference stack_limit_address =
117 ExternalReference::address_of_stack_limit(isolate); 76 ExternalReference::address_of_stack_limit(isolate);
118 CHECK_EQ(make_code(UNCLASSIFIED, 2), 77 CHECK_EQ(make_code(UNCLASSIFIED, 2),
119 encoder.Encode(stack_limit_address.address())); 78 encoder.Encode(stack_limit_address.address()));
120 ExternalReference real_stack_limit_address = 79 ExternalReference real_stack_limit_address =
121 ExternalReference::address_of_real_stack_limit(isolate); 80 ExternalReference::address_of_real_stack_limit(isolate);
122 CHECK_EQ(make_code(UNCLASSIFIED, 3), 81 CHECK_EQ(make_code(UNCLASSIFIED, 3),
123 encoder.Encode(real_stack_limit_address.address())); 82 encoder.Encode(real_stack_limit_address.address()));
124 CHECK_EQ(make_code(UNCLASSIFIED, 8), 83 CHECK_EQ(make_code(UNCLASSIFIED, 8),
125 encoder.Encode(ExternalReference::debug_break(isolate).address())); 84 encoder.Encode(ExternalReference::debug_break(isolate).address()));
126 CHECK_EQ( 85 CHECK_EQ(
127 make_code(UNCLASSIFIED, 4), 86 make_code(UNCLASSIFIED, 4),
128 encoder.Encode(ExternalReference::new_space_start(isolate).address())); 87 encoder.Encode(ExternalReference::new_space_start(isolate).address()));
129 CHECK_EQ( 88 CHECK_EQ(
130 make_code(UNCLASSIFIED, 1), 89 make_code(UNCLASSIFIED, 1),
131 encoder.Encode(ExternalReference::roots_array_start(isolate).address())); 90 encoder.Encode(ExternalReference::roots_array_start(isolate).address()));
132 CHECK_EQ(make_code(UNCLASSIFIED, 34), 91 CHECK_EQ(make_code(UNCLASSIFIED, 34),
133 encoder.Encode(ExternalReference::cpu_features().address())); 92 encoder.Encode(ExternalReference::cpu_features().address()));
134 } 93 }
135 94
136 95
137 TEST(ExternalReferenceDecoder) { 96 TEST(ExternalReferenceDecoder) {
138 Isolate* isolate = CcTest::i_isolate(); 97 Isolate* isolate = CcTest::i_isolate();
139 isolate->stats_table()->SetCounterFunction(counter_function);
140 v8::V8::Initialize(); 98 v8::V8::Initialize();
141 99
142 ExternalReferenceDecoder decoder(isolate); 100 ExternalReferenceDecoder decoder(isolate);
143 CHECK_EQ(AddressOf(Builtins::kArrayCode), 101 CHECK_EQ(AddressOf(Builtins::kArrayCode),
144 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); 102 decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode)));
145 CHECK_EQ(AddressOf(Runtime::kAbort), 103 CHECK_EQ(AddressOf(Runtime::kAbort),
146 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, 104 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION,
147 Runtime::kAbort))); 105 Runtime::kAbort)));
148 ExternalReference total_compile_size =
149 ExternalReference(isolate->counters()->total_compile_size());
150 CHECK_EQ(total_compile_size.address(),
151 decoder.Decode(
152 make_code(STATS_COUNTER,
153 Counters::k_total_compile_size)));
154 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), 106 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(),
155 decoder.Decode(make_code(UNCLASSIFIED, 2))); 107 decoder.Decode(make_code(UNCLASSIFIED, 2)));
156 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), 108 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(),
157 decoder.Decode(make_code(UNCLASSIFIED, 3))); 109 decoder.Decode(make_code(UNCLASSIFIED, 3)));
158 CHECK_EQ(ExternalReference::debug_break(isolate).address(), 110 CHECK_EQ(ExternalReference::debug_break(isolate).address(),
159 decoder.Decode(make_code(UNCLASSIFIED, 8))); 111 decoder.Decode(make_code(UNCLASSIFIED, 8)));
160 CHECK_EQ(ExternalReference::new_space_start(isolate).address(), 112 CHECK_EQ(ExternalReference::new_space_start(isolate).address(),
161 decoder.Decode(make_code(UNCLASSIFIED, 4))); 113 decoder.Decode(make_code(UNCLASSIFIED, 4)));
162 } 114 }
163 115
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 ser.CurrentAllocationAddress(OLD_DATA_SPACE), 187 ser.CurrentAllocationAddress(OLD_DATA_SPACE),
236 ser.CurrentAllocationAddress(CODE_SPACE), 188 ser.CurrentAllocationAddress(CODE_SPACE),
237 ser.CurrentAllocationAddress(MAP_SPACE), 189 ser.CurrentAllocationAddress(MAP_SPACE),
238 ser.CurrentAllocationAddress(CELL_SPACE), 190 ser.CurrentAllocationAddress(CELL_SPACE),
239 ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); 191 ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
240 192
241 return true; 193 return true;
242 } 194 }
243 195
244 196
245 static void Serialize() { 197 static void Serialize(v8::Isolate* isolate) {
246 // We have to create one context. One reason for this is so that the builtins 198 // We have to create one context. One reason for this is so that the builtins
247 // can be loaded from v8natives.js and their addresses can be processed. This 199 // can be loaded from v8natives.js and their addresses can be processed. This
248 // will clear the pending fixups array, which would otherwise contain GC roots 200 // will clear the pending fixups array, which would otherwise contain GC roots
249 // that would confuse the serialization/deserialization process. 201 // that would confuse the serialization/deserialization process.
250 v8::Isolate* isolate = CcTest::isolate();
251 { 202 {
252 v8::HandleScope scope(isolate); 203 v8::HandleScope scope(isolate);
253 v8::Context::New(isolate); 204 v8::Context::New(isolate);
254 } 205 }
255 206
256 Isolate* internal_isolate = CcTest::i_isolate(); 207 Isolate* internal_isolate = reinterpret_cast<Isolate*>(isolate);
257 internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize"); 208 internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize");
258 WriteToFile(internal_isolate, FLAG_testing_serialization_file); 209 WriteToFile(internal_isolate, FLAG_testing_serialization_file);
259 } 210 }
260 211
261 212
262 // Test that the whole heap can be serialized. 213 // Test that the whole heap can be serialized.
263 TEST(Serialize) { 214 UNINITIALIZED_TEST(Serialize) {
264 if (!Snapshot::HaveASnapshotToStartFrom()) { 215 if (!Snapshot::HaveASnapshotToStartFrom()) {
265 CcTest::i_isolate()->enable_serializer(); 216 v8::Isolate::CreateParams params;
266 v8::V8::Initialize(); 217 params.enable_serializer = true;
267 Serialize(); 218 v8::Isolate* isolate = v8::Isolate::New(params);
219 Serialize(isolate);
268 } 220 }
269 } 221 }
270 222
271 223
272 // Test that heap serialization is non-destructive. 224 // Test that heap serialization is non-destructive.
273 TEST(SerializeTwice) { 225 UNINITIALIZED_TEST(SerializeTwice) {
274 if (!Snapshot::HaveASnapshotToStartFrom()) { 226 if (!Snapshot::HaveASnapshotToStartFrom()) {
275 CcTest::i_isolate()->enable_serializer(); 227 v8::Isolate::CreateParams params;
276 v8::V8::Initialize(); 228 params.enable_serializer = true;
277 Serialize(); 229 v8::Isolate* isolate = v8::Isolate::New(params);
278 Serialize(); 230 Serialize(isolate);
231 Serialize(isolate);
279 } 232 }
280 } 233 }
281 234
282 235
283 //---------------------------------------------------------------------------- 236 //----------------------------------------------------------------------------
284 // Tests that the heap can be deserialized. 237 // Tests that the heap can be deserialized.
285 238
286 239
287 static void ReserveSpaceForSnapshot(Deserializer* deserializer, 240 static void ReserveSpaceForSnapshot(Deserializer* deserializer,
288 const char* file_name) { 241 const char* file_name) {
(...skipping 23 matching lines...) Expand all
312 deserializer->set_reservation(NEW_SPACE, new_size); 265 deserializer->set_reservation(NEW_SPACE, new_size);
313 deserializer->set_reservation(OLD_POINTER_SPACE, pointer_size); 266 deserializer->set_reservation(OLD_POINTER_SPACE, pointer_size);
314 deserializer->set_reservation(OLD_DATA_SPACE, data_size); 267 deserializer->set_reservation(OLD_DATA_SPACE, data_size);
315 deserializer->set_reservation(CODE_SPACE, code_size); 268 deserializer->set_reservation(CODE_SPACE, code_size);
316 deserializer->set_reservation(MAP_SPACE, map_size); 269 deserializer->set_reservation(MAP_SPACE, map_size);
317 deserializer->set_reservation(CELL_SPACE, cell_size); 270 deserializer->set_reservation(CELL_SPACE, cell_size);
318 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size); 271 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size);
319 } 272 }
320 273
321 274
322 bool InitializeFromFile(const char* snapshot_file) { 275 v8::Isolate* InitializeFromFile(const char* snapshot_file) {
323 int len; 276 int len;
324 byte* str = ReadBytes(snapshot_file, &len); 277 byte* str = ReadBytes(snapshot_file, &len);
325 if (!str) return false; 278 if (!str) return NULL;
326 bool success; 279 v8::Isolate* v8_isolate = NULL;
327 { 280 {
328 SnapshotByteSource source(str, len); 281 SnapshotByteSource source(str, len);
329 Deserializer deserializer(&source); 282 Deserializer deserializer(&source);
330 ReserveSpaceForSnapshot(&deserializer, snapshot_file); 283 ReserveSpaceForSnapshot(&deserializer, snapshot_file);
331 success = V8::Initialize(&deserializer); 284 Isolate* isolate = Isolate::NewForTesting();
285 v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
286 v8::Isolate::Scope isolate_scope(v8_isolate);
287 isolate->Init(&deserializer);
332 } 288 }
333 DeleteArray(str); 289 DeleteArray(str);
334 return success; 290 return v8_isolate;
335 } 291 }
336 292
337 293
338 static void Deserialize() { 294 static v8::Isolate* Deserialize() {
339 CHECK(InitializeFromFile(FLAG_testing_serialization_file)); 295 v8::Isolate* isolate = InitializeFromFile(FLAG_testing_serialization_file);
340 } 296 CHECK(isolate);
341 297 return isolate;
342 298 }
343 static void SanityCheck() { 299
344 Isolate* isolate = CcTest::i_isolate(); 300
345 v8::HandleScope scope(CcTest::isolate()); 301 static void SanityCheck(v8::Isolate* v8_isolate) {
302 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
303 v8::HandleScope scope(v8_isolate);
346 #ifdef VERIFY_HEAP 304 #ifdef VERIFY_HEAP
347 CcTest::heap()->Verify(); 305 isolate->heap()->Verify();
348 #endif 306 #endif
349 CHECK(isolate->global_object()->IsJSObject()); 307 CHECK(isolate->global_object()->IsJSObject());
350 CHECK(isolate->native_context()->IsContext()); 308 CHECK(isolate->native_context()->IsContext());
351 CHECK(CcTest::heap()->string_table()->IsStringTable()); 309 CHECK(isolate->heap()->string_table()->IsStringTable());
352 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); 310 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
353 } 311 }
354 312
355 313
356 DEPENDENT_TEST(Deserialize, Serialize) { 314 UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) {
357 // The serialize-deserialize tests only work if the VM is built without 315 // The serialize-deserialize tests only work if the VM is built without
358 // serialization. That doesn't matter. We don't need to be able to 316 // serialization. That doesn't matter. We don't need to be able to
359 // serialize a snapshot in a VM that is booted from a snapshot. 317 // serialize a snapshot in a VM that is booted from a snapshot.
360 if (!Snapshot::HaveASnapshotToStartFrom()) { 318 if (!Snapshot::HaveASnapshotToStartFrom()) {
361 v8::Isolate* isolate = CcTest::isolate(); 319 v8::Isolate* isolate = Deserialize();
362 v8::HandleScope scope(isolate); 320 {
363 Deserialize(); 321 v8::HandleScope handle_scope(isolate);
364 322 v8::Isolate::Scope isolate_scope(isolate);
365 v8::Local<v8::Context> env = v8::Context::New(isolate); 323
366 env->Enter(); 324 v8::Local<v8::Context> env = v8::Context::New(isolate);
367 325 env->Enter();
368 SanityCheck(); 326
369 } 327 SanityCheck(isolate);
370 } 328 }
371 329 isolate->Dispose();
372 330 }
373 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { 331 }
374 if (!Snapshot::HaveASnapshotToStartFrom()) { 332
375 v8::Isolate* isolate = CcTest::isolate(); 333
376 v8::HandleScope scope(isolate); 334 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization,
377 Deserialize(); 335 SerializeTwice) {
378 336 if (!Snapshot::HaveASnapshotToStartFrom()) {
379 v8::Local<v8::Context> env = v8::Context::New(isolate); 337 v8::Isolate* isolate = Deserialize();
380 env->Enter(); 338 {
381 339 v8::Isolate::Scope isolate_scope(isolate);
382 SanityCheck(); 340 v8::HandleScope handle_scope(isolate);
383 } 341
384 } 342 v8::Local<v8::Context> env = v8::Context::New(isolate);
385 343 env->Enter();
386 344
387 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { 345 SanityCheck(isolate);
388 if (!Snapshot::HaveASnapshotToStartFrom()) { 346 }
389 v8::Isolate* isolate = CcTest::isolate(); 347 isolate->Dispose();
390 v8::HandleScope scope(isolate); 348 }
391 Deserialize(); 349 }
392 350
393 v8::Local<v8::Context> env = v8::Context::New(isolate); 351
394 env->Enter(); 352 UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
395 353 if (!Snapshot::HaveASnapshotToStartFrom()) {
396 const char* c_source = "\"1234\".length"; 354 v8::Isolate* isolate = Deserialize();
397 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); 355 {
398 v8::Local<v8::Script> script = v8::Script::Compile(source); 356 v8::Isolate::Scope isolate_scope(isolate);
399 CHECK_EQ(4, script->Run()->Int32Value()); 357 v8::HandleScope handle_scope(isolate);
400 } 358
401 } 359
402 360 v8::Local<v8::Context> env = v8::Context::New(isolate);
403 361 env->Enter();
404 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, 362
405 SerializeTwice) { 363 const char* c_source = "\"1234\".length";
406 if (!Snapshot::HaveASnapshotToStartFrom()) { 364 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
407 v8::Isolate* isolate = CcTest::isolate(); 365 v8::Local<v8::Script> script = v8::Script::Compile(source);
408 v8::HandleScope scope(isolate); 366 CHECK_EQ(4, script->Run()->Int32Value());
409 Deserialize(); 367 }
410 368 isolate->Dispose();
411 v8::Local<v8::Context> env = v8::Context::New(isolate); 369 }
412 env->Enter(); 370 }
413 371
414 const char* c_source = "\"1234\".length"; 372
415 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); 373 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
416 v8::Local<v8::Script> script = v8::Script::Compile(source); 374 SerializeTwice) {
417 CHECK_EQ(4, script->Run()->Int32Value()); 375 if (!Snapshot::HaveASnapshotToStartFrom()) {
418 } 376 v8::Isolate* isolate = Deserialize();
419 } 377 {
420 378 v8::Isolate::Scope isolate_scope(isolate);
421 379 v8::HandleScope handle_scope(isolate);
422 TEST(PartialSerialization) { 380
423 if (!Snapshot::HaveASnapshotToStartFrom()) { 381 v8::Local<v8::Context> env = v8::Context::New(isolate);
424 Isolate* isolate = CcTest::i_isolate(); 382 env->Enter();
425 CcTest::i_isolate()->enable_serializer(); 383
426 v8::V8::Initialize(); 384 const char* c_source = "\"1234\".length";
427 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 385 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
428 Heap* heap = isolate->heap(); 386 v8::Local<v8::Script> script = v8::Script::Compile(source);
429 387 CHECK_EQ(4, script->Run()->Int32Value());
430 v8::Persistent<v8::Context> env; 388 }
431 { 389 isolate->Dispose();
432 HandleScope scope(isolate); 390 }
433 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 391 }
434 } 392
435 DCHECK(!env.IsEmpty()); 393
436 { 394 UNINITIALIZED_TEST(PartialSerialization) {
437 v8::HandleScope handle_scope(v8_isolate); 395 if (!Snapshot::HaveASnapshotToStartFrom()) {
438 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); 396 v8::Isolate::CreateParams params;
439 } 397 params.enable_serializer = true;
440 // Make sure all builtin scripts are cached. 398 v8::Isolate* v8_isolate = v8::Isolate::New(params);
441 { HandleScope scope(isolate); 399 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
442 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 400 v8_isolate->Enter();
443 isolate->bootstrapper()->NativesSourceLookup(i); 401 {
444 } 402 Heap* heap = isolate->heap();
445 } 403
446 heap->CollectAllGarbage(Heap::kNoGCFlags); 404 v8::Persistent<v8::Context> env;
447 heap->CollectAllGarbage(Heap::kNoGCFlags); 405 {
448 406 HandleScope scope(isolate);
449 Object* raw_foo; 407 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
450 { 408 }
451 v8::HandleScope handle_scope(v8_isolate); 409 DCHECK(!env.IsEmpty());
452 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); 410 {
453 DCHECK(!foo.IsEmpty()); 411 v8::HandleScope handle_scope(v8_isolate);
454 raw_foo = *(v8::Utils::OpenHandle(*foo)); 412 v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
455 } 413 }
456 414 // Make sure all builtin scripts are cached.
415 {
416 HandleScope scope(isolate);
417 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
418 isolate->bootstrapper()->NativesSourceLookup(i);
419 }
420 }
421 heap->CollectAllGarbage(Heap::kNoGCFlags);
422 heap->CollectAllGarbage(Heap::kNoGCFlags);
423
424 Object* raw_foo;
425 {
426 v8::HandleScope handle_scope(v8_isolate);
427 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo");
428 DCHECK(!foo.IsEmpty());
429 raw_foo = *(v8::Utils::OpenHandle(*foo));
430 }
431
432 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
433 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
434 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
435
436 {
437 v8::HandleScope handle_scope(v8_isolate);
438 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
439 }
440 env.Reset();
441
442 FileByteSink startup_sink(startup_name.start());
443 StartupSerializer startup_serializer(isolate, &startup_sink);
444 startup_serializer.SerializeStrongReferences();
445
446 FileByteSink partial_sink(FLAG_testing_serialization_file);
447 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
448 p_ser.Serialize(&raw_foo);
449 startup_serializer.SerializeWeakReferences();
450
451 partial_sink.WriteSpaceUsed(
452 p_ser.CurrentAllocationAddress(NEW_SPACE),
453 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
454 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
455 p_ser.CurrentAllocationAddress(CODE_SPACE),
456 p_ser.CurrentAllocationAddress(MAP_SPACE),
457 p_ser.CurrentAllocationAddress(CELL_SPACE),
458 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
459
460 startup_sink.WriteSpaceUsed(
461 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
462 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
463 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
464 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
465 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
466 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
467 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
468 startup_name.Dispose();
469 }
470 v8_isolate->Exit();
471 v8_isolate->Dispose();
472 }
473 }
474
475
476 UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
477 if (!Snapshot::HaveASnapshotToStartFrom()) {
457 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 478 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
458 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 479 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
459 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 480 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
460 481
461 { 482 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
462 v8::HandleScope handle_scope(v8_isolate); 483 CHECK(v8_isolate);
463 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
464 }
465 env.Reset();
466
467 FileByteSink startup_sink(startup_name.start());
468 StartupSerializer startup_serializer(isolate, &startup_sink);
469 startup_serializer.SerializeStrongReferences();
470
471 FileByteSink partial_sink(FLAG_testing_serialization_file);
472 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
473 p_ser.Serialize(&raw_foo);
474 startup_serializer.SerializeWeakReferences();
475
476 partial_sink.WriteSpaceUsed(
477 p_ser.CurrentAllocationAddress(NEW_SPACE),
478 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
479 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
480 p_ser.CurrentAllocationAddress(CODE_SPACE),
481 p_ser.CurrentAllocationAddress(MAP_SPACE),
482 p_ser.CurrentAllocationAddress(CELL_SPACE),
483 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
484
485 startup_sink.WriteSpaceUsed(
486 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
487 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
488 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
489 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
490 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
491 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
492 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
493 startup_name.Dispose(); 484 startup_name.Dispose();
494 } 485 {
495 } 486 v8::Isolate::Scope isolate_scope(v8_isolate);
496 487
497 488 const char* file_name = FLAG_testing_serialization_file;
498 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { 489
490 int snapshot_size = 0;
491 byte* snapshot = ReadBytes(file_name, &snapshot_size);
492
493 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
494 Object* root;
495 {
496 SnapshotByteSource source(snapshot, snapshot_size);
497 Deserializer deserializer(&source);
498 ReserveSpaceForSnapshot(&deserializer, file_name);
499 deserializer.DeserializePartial(isolate, &root);
500 CHECK(root->IsString());
501 }
502 HandleScope handle_scope(isolate);
503 Handle<Object> root_handle(root, isolate);
504
505
506 Object* root2;
507 {
508 SnapshotByteSource source(snapshot, snapshot_size);
509 Deserializer deserializer(&source);
510 ReserveSpaceForSnapshot(&deserializer, file_name);
511 deserializer.DeserializePartial(isolate, &root2);
512 CHECK(root2->IsString());
513 CHECK(*root_handle == root2);
514 }
515 }
516 v8_isolate->Dispose();
517 }
518 }
519
520
521 UNINITIALIZED_TEST(ContextSerialization) {
522 if (!Snapshot::HaveASnapshotToStartFrom()) {
523 v8::Isolate::CreateParams params;
524 params.enable_serializer = true;
525 v8::Isolate* v8_isolate = v8::Isolate::New(params);
526 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
527 Heap* heap = isolate->heap();
528 {
529 v8::Isolate::Scope isolate_scope(v8_isolate);
530
531 v8::Persistent<v8::Context> env;
532 {
533 HandleScope scope(isolate);
534 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
535 }
536 DCHECK(!env.IsEmpty());
537 {
538 v8::HandleScope handle_scope(v8_isolate);
539 v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
540 }
541 // Make sure all builtin scripts are cached.
542 {
543 HandleScope scope(isolate);
544 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
545 isolate->bootstrapper()->NativesSourceLookup(i);
546 }
547 }
548 // If we don't do this then we end up with a stray root pointing at the
549 // context even after we have disposed of env.
550 heap->CollectAllGarbage(Heap::kNoGCFlags);
551
552 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
553 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
554 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
555
556 {
557 v8::HandleScope handle_scope(v8_isolate);
558 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
559 }
560
561 i::Object* raw_context = *v8::Utils::OpenPersistent(env);
562
563 env.Reset();
564
565 FileByteSink startup_sink(startup_name.start());
566 StartupSerializer startup_serializer(isolate, &startup_sink);
567 startup_serializer.SerializeStrongReferences();
568
569 FileByteSink partial_sink(FLAG_testing_serialization_file);
570 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
571 p_ser.Serialize(&raw_context);
572 startup_serializer.SerializeWeakReferences();
573
574 partial_sink.WriteSpaceUsed(
575 p_ser.CurrentAllocationAddress(NEW_SPACE),
576 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
577 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
578 p_ser.CurrentAllocationAddress(CODE_SPACE),
579 p_ser.CurrentAllocationAddress(MAP_SPACE),
580 p_ser.CurrentAllocationAddress(CELL_SPACE),
581 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
582
583 startup_sink.WriteSpaceUsed(
584 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
585 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
586 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
587 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
588 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
589 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
590 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
591 startup_name.Dispose();
592 }
593 v8_isolate->Dispose();
594 }
595 }
596
597
598 UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
499 if (!Snapshot::HaveASnapshotToStartFrom()) { 599 if (!Snapshot::HaveASnapshotToStartFrom()) {
500 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 600 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
501 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 601 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
502 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 602 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
503 603
504 CHECK(InitializeFromFile(startup_name.start())); 604 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
605 CHECK(v8_isolate);
505 startup_name.Dispose(); 606 startup_name.Dispose();
506 607 {
507 const char* file_name = FLAG_testing_serialization_file; 608 v8::Isolate::Scope isolate_scope(v8_isolate);
508 609
509 int snapshot_size = 0; 610 const char* file_name = FLAG_testing_serialization_file;
510 byte* snapshot = ReadBytes(file_name, &snapshot_size); 611
511 612 int snapshot_size = 0;
512 Isolate* isolate = CcTest::i_isolate(); 613 byte* snapshot = ReadBytes(file_name, &snapshot_size);
513 Object* root; 614
514 { 615 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
515 SnapshotByteSource source(snapshot, snapshot_size); 616 Object* root;
516 Deserializer deserializer(&source); 617 {
517 ReserveSpaceForSnapshot(&deserializer, file_name); 618 SnapshotByteSource source(snapshot, snapshot_size);
518 deserializer.DeserializePartial(isolate, &root); 619 Deserializer deserializer(&source);
519 CHECK(root->IsString()); 620 ReserveSpaceForSnapshot(&deserializer, file_name);
520 } 621 deserializer.DeserializePartial(isolate, &root);
521 HandleScope handle_scope(isolate); 622 CHECK(root->IsContext());
522 Handle<Object> root_handle(root, isolate); 623 }
523 624 HandleScope handle_scope(isolate);
524 625 Handle<Object> root_handle(root, isolate);
525 Object* root2; 626
526 { 627
527 SnapshotByteSource source(snapshot, snapshot_size); 628 Object* root2;
528 Deserializer deserializer(&source); 629 {
529 ReserveSpaceForSnapshot(&deserializer, file_name); 630 SnapshotByteSource source(snapshot, snapshot_size);
530 deserializer.DeserializePartial(isolate, &root2); 631 Deserializer deserializer(&source);
531 CHECK(root2->IsString()); 632 ReserveSpaceForSnapshot(&deserializer, file_name);
532 CHECK(*root_handle == root2); 633 deserializer.DeserializePartial(isolate, &root2);
533 } 634 CHECK(root2->IsContext());
534 } 635 CHECK(*root_handle != root2);
535 } 636 }
536 637 }
537 638 v8_isolate->Dispose();
538 TEST(ContextSerialization) { 639 }
539 if (!Snapshot::HaveASnapshotToStartFrom()) { 640 }
540 Isolate* isolate = CcTest::i_isolate(); 641
541 CcTest::i_isolate()->enable_serializer();
542 v8::V8::Initialize();
543 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
544 Heap* heap = isolate->heap();
545
546 v8::Persistent<v8::Context> env;
547 {
548 HandleScope scope(isolate);
549 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
550 }
551 DCHECK(!env.IsEmpty());
552 {
553 v8::HandleScope handle_scope(v8_isolate);
554 v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
555 }
556 // Make sure all builtin scripts are cached.
557 { HandleScope scope(isolate);
558 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
559 isolate->bootstrapper()->NativesSourceLookup(i);
560 }
561 }
562 // If we don't do this then we end up with a stray root pointing at the
563 // context even after we have disposed of env.
564 heap->CollectAllGarbage(Heap::kNoGCFlags);
565
566 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
567 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
568 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
569
570 {
571 v8::HandleScope handle_scope(v8_isolate);
572 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
573 }
574
575 i::Object* raw_context = *v8::Utils::OpenPersistent(env);
576
577 env.Reset();
578
579 FileByteSink startup_sink(startup_name.start());
580 StartupSerializer startup_serializer(isolate, &startup_sink);
581 startup_serializer.SerializeStrongReferences();
582
583 FileByteSink partial_sink(FLAG_testing_serialization_file);
584 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
585 p_ser.Serialize(&raw_context);
586 startup_serializer.SerializeWeakReferences();
587
588 partial_sink.WriteSpaceUsed(
589 p_ser.CurrentAllocationAddress(NEW_SPACE),
590 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
591 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
592 p_ser.CurrentAllocationAddress(CODE_SPACE),
593 p_ser.CurrentAllocationAddress(MAP_SPACE),
594 p_ser.CurrentAllocationAddress(CELL_SPACE),
595 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
596
597 startup_sink.WriteSpaceUsed(
598 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
599 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
600 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
601 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
602 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
603 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
604 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
605 startup_name.Dispose();
606 }
607 }
608
609
610 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
611 if (!Snapshot::HaveASnapshotToStartFrom()) {
612 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
613 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
614 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
615
616 CHECK(InitializeFromFile(startup_name.start()));
617 startup_name.Dispose();
618
619 const char* file_name = FLAG_testing_serialization_file;
620
621 int snapshot_size = 0;
622 byte* snapshot = ReadBytes(file_name, &snapshot_size);
623
624 Isolate* isolate = CcTest::i_isolate();
625 Object* root;
626 {
627 SnapshotByteSource source(snapshot, snapshot_size);
628 Deserializer deserializer(&source);
629 ReserveSpaceForSnapshot(&deserializer, file_name);
630 deserializer.DeserializePartial(isolate, &root);
631 CHECK(root->IsContext());
632 }
633 HandleScope handle_scope(isolate);
634 Handle<Object> root_handle(root, isolate);
635
636
637 Object* root2;
638 {
639 SnapshotByteSource source(snapshot, snapshot_size);
640 Deserializer deserializer(&source);
641 ReserveSpaceForSnapshot(&deserializer, file_name);
642 deserializer.DeserializePartial(isolate, &root2);
643 CHECK(root2->IsContext());
644 CHECK(*root_handle != root2);
645 }
646 }
647 }
648
649 642
650 TEST(TestThatAlwaysSucceeds) { 643 TEST(TestThatAlwaysSucceeds) {
651 } 644 }
652 645
653 646
654 TEST(TestThatAlwaysFails) { 647 TEST(TestThatAlwaysFails) {
655 bool ArtificialFailure = false; 648 bool ArtificialFailure = false;
656 CHECK(ArtificialFailure); 649 CHECK(ArtificialFailure);
657 } 650 }
658 651
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 } 785 }
793 786
794 787
795 TEST(SerializeToplevelIsolates) { 788 TEST(SerializeToplevelIsolates) {
796 FLAG_serialize_toplevel = true; 789 FLAG_serialize_toplevel = true;
797 790
798 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 791 const char* source = "function f() { return 'abc'; }; f() + 'def'";
799 v8::ScriptCompiler::CachedData* cache; 792 v8::ScriptCompiler::CachedData* cache;
800 793
801 v8::Isolate* isolate1 = v8::Isolate::New(); 794 v8::Isolate* isolate1 = v8::Isolate::New();
802 v8::Isolate* isolate2 = v8::Isolate::New();
803 { 795 {
804 v8::Isolate::Scope iscope(isolate1); 796 v8::Isolate::Scope iscope(isolate1);
805 v8::HandleScope scope(isolate1); 797 v8::HandleScope scope(isolate1);
806 v8::Local<v8::Context> context = v8::Context::New(isolate1); 798 v8::Local<v8::Context> context = v8::Context::New(isolate1);
807 v8::Context::Scope context_scope(context); 799 v8::Context::Scope context_scope(context);
808 800
809 v8::Local<v8::String> source_str = v8_str(source); 801 v8::Local<v8::String> source_str = v8_str(source);
810 v8::ScriptOrigin origin(v8_str("test")); 802 v8::ScriptOrigin origin(v8_str("test"));
811 v8::ScriptCompiler::Source source(source_str, origin); 803 v8::ScriptCompiler::Source source(source_str, origin);
812 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( 804 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
813 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); 805 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
814 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); 806 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
815 // Persist cached data. 807 // Persist cached data.
816 uint8_t* buffer = NewArray<uint8_t>(data->length); 808 uint8_t* buffer = NewArray<uint8_t>(data->length);
817 MemCopy(buffer, data->data, data->length); 809 MemCopy(buffer, data->data, data->length);
818 cache = new v8::ScriptCompiler::CachedData( 810 cache = new v8::ScriptCompiler::CachedData(
819 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); 811 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
820 812
821 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 813 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
822 CHECK(result->ToString()->Equals(v8_str("abcdef"))); 814 CHECK(result->ToString()->Equals(v8_str("abcdef")));
823 } 815 }
824 isolate1->Dispose(); 816 isolate1->Dispose();
825 817
818 v8::Isolate* isolate2 = v8::Isolate::New();
826 { 819 {
827 v8::Isolate::Scope iscope(isolate2); 820 v8::Isolate::Scope iscope(isolate2);
828 v8::HandleScope scope(isolate2); 821 v8::HandleScope scope(isolate2);
829 v8::Local<v8::Context> context = v8::Context::New(isolate2); 822 v8::Local<v8::Context> context = v8::Context::New(isolate2);
830 v8::Context::Scope context_scope(context); 823 v8::Context::Scope context_scope(context);
831 824
832 v8::Local<v8::String> source_str = v8_str(source); 825 v8::Local<v8::String> source_str = v8_str(source);
833 v8::ScriptOrigin origin(v8_str("test")); 826 v8::ScriptOrigin origin(v8_str("test"));
834 v8::ScriptCompiler::Source source(source_str, origin, cache); 827 v8::ScriptCompiler::Source source(source_str, origin, cache);
835 v8::Local<v8::UnboundScript> script; 828 v8::Local<v8::UnboundScript> script;
836 { 829 {
837 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 830 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
838 script = v8::ScriptCompiler::CompileUnbound( 831 script = v8::ScriptCompiler::CompileUnbound(
839 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 832 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
840 } 833 }
841 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 834 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
842 CHECK(result->ToString()->Equals(v8_str("abcdef"))); 835 CHECK(result->ToString()->Equals(v8_str("abcdef")));
843 } 836 }
844 isolate2->Dispose(); 837 isolate2->Dispose();
845 } 838 }
OLDNEW
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698