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

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

Issue 583153002: Reland 24052 - Require V8 to be explicitly initialized before an Isolate is created (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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(); 202 v8::Isolate::Scope isolate_scope(isolate);
251 { 203 {
252 v8::HandleScope scope(isolate); 204 v8::HandleScope scope(isolate);
253 v8::Context::New(isolate); 205 v8::Context::New(isolate);
254 } 206 }
255 207
256 Isolate* internal_isolate = CcTest::i_isolate(); 208 Isolate* internal_isolate = reinterpret_cast<Isolate*>(isolate);
257 internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize"); 209 internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize");
258 WriteToFile(internal_isolate, FLAG_testing_serialization_file); 210 WriteToFile(internal_isolate, FLAG_testing_serialization_file);
259 } 211 }
260 212
261 213
262 // Test that the whole heap can be serialized. 214 // Test that the whole heap can be serialized.
263 TEST(Serialize) { 215 UNINITIALIZED_TEST(Serialize) {
264 if (!Snapshot::HaveASnapshotToStartFrom()) { 216 if (!Snapshot::HaveASnapshotToStartFrom()) {
265 CcTest::i_isolate()->enable_serializer(); 217 v8::Isolate::CreateParams params;
266 v8::V8::Initialize(); 218 params.enable_serializer = true;
267 Serialize(); 219 v8::Isolate* isolate = v8::Isolate::New(params);
220 Serialize(isolate);
268 } 221 }
269 } 222 }
270 223
271 224
272 // Test that heap serialization is non-destructive. 225 // Test that heap serialization is non-destructive.
273 TEST(SerializeTwice) { 226 UNINITIALIZED_TEST(SerializeTwice) {
274 if (!Snapshot::HaveASnapshotToStartFrom()) { 227 if (!Snapshot::HaveASnapshotToStartFrom()) {
275 CcTest::i_isolate()->enable_serializer(); 228 v8::Isolate::CreateParams params;
276 v8::V8::Initialize(); 229 params.enable_serializer = true;
277 Serialize(); 230 v8::Isolate* isolate = v8::Isolate::New(params);
278 Serialize(); 231 Serialize(isolate);
232 Serialize(isolate);
279 } 233 }
280 } 234 }
281 235
282 236
283 //---------------------------------------------------------------------------- 237 //----------------------------------------------------------------------------
284 // Tests that the heap can be deserialized. 238 // Tests that the heap can be deserialized.
285 239
286 240
287 static void ReserveSpaceForSnapshot(Deserializer* deserializer, 241 static void ReserveSpaceForSnapshot(Deserializer* deserializer,
288 const char* file_name) { 242 const char* file_name) {
(...skipping 23 matching lines...) Expand all
312 deserializer->set_reservation(NEW_SPACE, new_size); 266 deserializer->set_reservation(NEW_SPACE, new_size);
313 deserializer->set_reservation(OLD_POINTER_SPACE, pointer_size); 267 deserializer->set_reservation(OLD_POINTER_SPACE, pointer_size);
314 deserializer->set_reservation(OLD_DATA_SPACE, data_size); 268 deserializer->set_reservation(OLD_DATA_SPACE, data_size);
315 deserializer->set_reservation(CODE_SPACE, code_size); 269 deserializer->set_reservation(CODE_SPACE, code_size);
316 deserializer->set_reservation(MAP_SPACE, map_size); 270 deserializer->set_reservation(MAP_SPACE, map_size);
317 deserializer->set_reservation(CELL_SPACE, cell_size); 271 deserializer->set_reservation(CELL_SPACE, cell_size);
318 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size); 272 deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size);
319 } 273 }
320 274
321 275
322 bool InitializeFromFile(const char* snapshot_file) { 276 v8::Isolate* InitializeFromFile(const char* snapshot_file) {
323 int len; 277 int len;
324 byte* str = ReadBytes(snapshot_file, &len); 278 byte* str = ReadBytes(snapshot_file, &len);
325 if (!str) return false; 279 if (!str) return NULL;
326 bool success; 280 v8::Isolate* v8_isolate = NULL;
327 { 281 {
328 SnapshotByteSource source(str, len); 282 SnapshotByteSource source(str, len);
329 Deserializer deserializer(&source); 283 Deserializer deserializer(&source);
330 ReserveSpaceForSnapshot(&deserializer, snapshot_file); 284 ReserveSpaceForSnapshot(&deserializer, snapshot_file);
331 success = V8::Initialize(&deserializer); 285 Isolate* isolate = Isolate::NewForTesting();
286 v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
287 v8::Isolate::Scope isolate_scope(v8_isolate);
288 isolate->Init(&deserializer);
332 } 289 }
333 DeleteArray(str); 290 DeleteArray(str);
334 return success; 291 return v8_isolate;
335 } 292 }
336 293
337 294
338 static void Deserialize() { 295 static v8::Isolate* Deserialize() {
339 CHECK(InitializeFromFile(FLAG_testing_serialization_file)); 296 v8::Isolate* isolate = InitializeFromFile(FLAG_testing_serialization_file);
340 } 297 CHECK(isolate);
341 298 return isolate;
342 299 }
343 static void SanityCheck() { 300
344 Isolate* isolate = CcTest::i_isolate(); 301
345 v8::HandleScope scope(CcTest::isolate()); 302 static void SanityCheck(v8::Isolate* v8_isolate) {
303 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
304 v8::HandleScope scope(v8_isolate);
346 #ifdef VERIFY_HEAP 305 #ifdef VERIFY_HEAP
347 CcTest::heap()->Verify(); 306 isolate->heap()->Verify();
348 #endif 307 #endif
349 CHECK(isolate->global_object()->IsJSObject()); 308 CHECK(isolate->global_object()->IsJSObject());
350 CHECK(isolate->native_context()->IsContext()); 309 CHECK(isolate->native_context()->IsContext());
351 CHECK(CcTest::heap()->string_table()->IsStringTable()); 310 CHECK(isolate->heap()->string_table()->IsStringTable());
352 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); 311 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
353 } 312 }
354 313
355 314
356 DEPENDENT_TEST(Deserialize, Serialize) { 315 UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) {
357 // The serialize-deserialize tests only work if the VM is built without 316 // 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 317 // 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. 318 // serialize a snapshot in a VM that is booted from a snapshot.
360 if (!Snapshot::HaveASnapshotToStartFrom()) { 319 if (!Snapshot::HaveASnapshotToStartFrom()) {
361 v8::Isolate* isolate = CcTest::isolate(); 320 v8::Isolate* isolate = Deserialize();
362 v8::HandleScope scope(isolate); 321 {
363 Deserialize(); 322 v8::HandleScope handle_scope(isolate);
364 323 v8::Isolate::Scope isolate_scope(isolate);
365 v8::Local<v8::Context> env = v8::Context::New(isolate); 324
366 env->Enter(); 325 v8::Local<v8::Context> env = v8::Context::New(isolate);
367 326 env->Enter();
368 SanityCheck(); 327
369 } 328 SanityCheck(isolate);
370 } 329 }
371 330 isolate->Dispose();
372 331 }
373 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { 332 }
374 if (!Snapshot::HaveASnapshotToStartFrom()) { 333
375 v8::Isolate* isolate = CcTest::isolate(); 334
376 v8::HandleScope scope(isolate); 335 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization,
377 Deserialize(); 336 SerializeTwice) {
378 337 if (!Snapshot::HaveASnapshotToStartFrom()) {
379 v8::Local<v8::Context> env = v8::Context::New(isolate); 338 v8::Isolate* isolate = Deserialize();
380 env->Enter(); 339 {
381 340 v8::Isolate::Scope isolate_scope(isolate);
382 SanityCheck(); 341 v8::HandleScope handle_scope(isolate);
383 } 342
384 } 343 v8::Local<v8::Context> env = v8::Context::New(isolate);
385 344 env->Enter();
386 345
387 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { 346 SanityCheck(isolate);
388 if (!Snapshot::HaveASnapshotToStartFrom()) { 347 }
389 v8::Isolate* isolate = CcTest::isolate(); 348 isolate->Dispose();
390 v8::HandleScope scope(isolate); 349 }
391 Deserialize(); 350 }
392 351
393 v8::Local<v8::Context> env = v8::Context::New(isolate); 352
394 env->Enter(); 353 UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
395 354 if (!Snapshot::HaveASnapshotToStartFrom()) {
396 const char* c_source = "\"1234\".length"; 355 v8::Isolate* isolate = Deserialize();
397 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); 356 {
398 v8::Local<v8::Script> script = v8::Script::Compile(source); 357 v8::Isolate::Scope isolate_scope(isolate);
399 CHECK_EQ(4, script->Run()->Int32Value()); 358 v8::HandleScope handle_scope(isolate);
400 } 359
401 } 360
402 361 v8::Local<v8::Context> env = v8::Context::New(isolate);
403 362 env->Enter();
404 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, 363
405 SerializeTwice) { 364 const char* c_source = "\"1234\".length";
406 if (!Snapshot::HaveASnapshotToStartFrom()) { 365 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
407 v8::Isolate* isolate = CcTest::isolate(); 366 v8::Local<v8::Script> script = v8::Script::Compile(source);
408 v8::HandleScope scope(isolate); 367 CHECK_EQ(4, script->Run()->Int32Value());
409 Deserialize(); 368 }
410 369 isolate->Dispose();
411 v8::Local<v8::Context> env = v8::Context::New(isolate); 370 }
412 env->Enter(); 371 }
413 372
414 const char* c_source = "\"1234\".length"; 373
415 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); 374 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
416 v8::Local<v8::Script> script = v8::Script::Compile(source); 375 SerializeTwice) {
417 CHECK_EQ(4, script->Run()->Int32Value()); 376 if (!Snapshot::HaveASnapshotToStartFrom()) {
418 } 377 v8::Isolate* isolate = Deserialize();
419 } 378 {
420 379 v8::Isolate::Scope isolate_scope(isolate);
421 380 v8::HandleScope handle_scope(isolate);
422 TEST(PartialSerialization) { 381
423 if (!Snapshot::HaveASnapshotToStartFrom()) { 382 v8::Local<v8::Context> env = v8::Context::New(isolate);
424 Isolate* isolate = CcTest::i_isolate(); 383 env->Enter();
425 CcTest::i_isolate()->enable_serializer(); 384
426 v8::V8::Initialize(); 385 const char* c_source = "\"1234\".length";
427 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 386 v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source);
428 Heap* heap = isolate->heap(); 387 v8::Local<v8::Script> script = v8::Script::Compile(source);
429 388 CHECK_EQ(4, script->Run()->Int32Value());
430 v8::Persistent<v8::Context> env; 389 }
431 { 390 isolate->Dispose();
432 HandleScope scope(isolate); 391 }
433 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 392 }
434 } 393
435 DCHECK(!env.IsEmpty()); 394
436 { 395 UNINITIALIZED_TEST(PartialSerialization) {
437 v8::HandleScope handle_scope(v8_isolate); 396 if (!Snapshot::HaveASnapshotToStartFrom()) {
438 v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); 397 v8::Isolate::CreateParams params;
439 } 398 params.enable_serializer = true;
440 // Make sure all builtin scripts are cached. 399 v8::Isolate* v8_isolate = v8::Isolate::New(params);
441 { HandleScope scope(isolate); 400 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
442 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { 401 v8_isolate->Enter();
443 isolate->bootstrapper()->NativesSourceLookup(i); 402 {
444 } 403 Heap* heap = isolate->heap();
445 } 404
446 heap->CollectAllGarbage(Heap::kNoGCFlags); 405 v8::Persistent<v8::Context> env;
447 heap->CollectAllGarbage(Heap::kNoGCFlags); 406 {
448 407 HandleScope scope(isolate);
449 Object* raw_foo; 408 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
450 { 409 }
451 v8::HandleScope handle_scope(v8_isolate); 410 DCHECK(!env.IsEmpty());
452 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); 411 {
453 DCHECK(!foo.IsEmpty()); 412 v8::HandleScope handle_scope(v8_isolate);
454 raw_foo = *(v8::Utils::OpenHandle(*foo)); 413 v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
455 } 414 }
456 415 // Make sure all builtin scripts are cached.
416 {
417 HandleScope scope(isolate);
418 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
419 isolate->bootstrapper()->NativesSourceLookup(i);
420 }
421 }
422 heap->CollectAllGarbage(Heap::kNoGCFlags);
423 heap->CollectAllGarbage(Heap::kNoGCFlags);
424
425 Object* raw_foo;
426 {
427 v8::HandleScope handle_scope(v8_isolate);
428 v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo");
429 DCHECK(!foo.IsEmpty());
430 raw_foo = *(v8::Utils::OpenHandle(*foo));
431 }
432
433 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
434 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
435 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
436
437 {
438 v8::HandleScope handle_scope(v8_isolate);
439 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
440 }
441 env.Reset();
442
443 FileByteSink startup_sink(startup_name.start());
444 StartupSerializer startup_serializer(isolate, &startup_sink);
445 startup_serializer.SerializeStrongReferences();
446
447 FileByteSink partial_sink(FLAG_testing_serialization_file);
448 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
449 p_ser.Serialize(&raw_foo);
450 startup_serializer.SerializeWeakReferences();
451
452 partial_sink.WriteSpaceUsed(
453 p_ser.CurrentAllocationAddress(NEW_SPACE),
454 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
455 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
456 p_ser.CurrentAllocationAddress(CODE_SPACE),
457 p_ser.CurrentAllocationAddress(MAP_SPACE),
458 p_ser.CurrentAllocationAddress(CELL_SPACE),
459 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
460
461 startup_sink.WriteSpaceUsed(
462 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
463 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
464 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
465 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
466 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
467 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
468 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
469 startup_name.Dispose();
470 }
471 v8_isolate->Exit();
472 v8_isolate->Dispose();
473 }
474 }
475
476
477 UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
478 if (!Snapshot::HaveASnapshotToStartFrom()) {
457 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 479 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
458 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 480 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
459 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 481 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
460 482
461 { 483 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
462 v8::HandleScope handle_scope(v8_isolate); 484 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(); 485 startup_name.Dispose();
494 } 486 {
495 } 487 v8::Isolate::Scope isolate_scope(v8_isolate);
496 488
497 489 const char* file_name = FLAG_testing_serialization_file;
498 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { 490
491 int snapshot_size = 0;
492 byte* snapshot = ReadBytes(file_name, &snapshot_size);
493
494 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
495 Object* root;
496 {
497 SnapshotByteSource source(snapshot, snapshot_size);
498 Deserializer deserializer(&source);
499 ReserveSpaceForSnapshot(&deserializer, file_name);
500 deserializer.DeserializePartial(isolate, &root);
501 CHECK(root->IsString());
502 }
503 HandleScope handle_scope(isolate);
504 Handle<Object> root_handle(root, isolate);
505
506
507 Object* root2;
508 {
509 SnapshotByteSource source(snapshot, snapshot_size);
510 Deserializer deserializer(&source);
511 ReserveSpaceForSnapshot(&deserializer, file_name);
512 deserializer.DeserializePartial(isolate, &root2);
513 CHECK(root2->IsString());
514 CHECK(*root_handle == root2);
515 }
516 }
517 v8_isolate->Dispose();
518 }
519 }
520
521
522 UNINITIALIZED_TEST(ContextSerialization) {
523 if (!Snapshot::HaveASnapshotToStartFrom()) {
524 v8::Isolate::CreateParams params;
525 params.enable_serializer = true;
526 v8::Isolate* v8_isolate = v8::Isolate::New(params);
527 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
528 Heap* heap = isolate->heap();
529 {
530 v8::Isolate::Scope isolate_scope(v8_isolate);
531
532 v8::Persistent<v8::Context> env;
533 {
534 HandleScope scope(isolate);
535 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
536 }
537 DCHECK(!env.IsEmpty());
538 {
539 v8::HandleScope handle_scope(v8_isolate);
540 v8::Local<v8::Context>::New(v8_isolate, env)->Enter();
541 }
542 // Make sure all builtin scripts are cached.
543 {
544 HandleScope scope(isolate);
545 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) {
546 isolate->bootstrapper()->NativesSourceLookup(i);
547 }
548 }
549 // If we don't do this then we end up with a stray root pointing at the
550 // context even after we have disposed of env.
551 heap->CollectAllGarbage(Heap::kNoGCFlags);
552
553 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
554 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
555 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
556
557 {
558 v8::HandleScope handle_scope(v8_isolate);
559 v8::Local<v8::Context>::New(v8_isolate, env)->Exit();
560 }
561
562 i::Object* raw_context = *v8::Utils::OpenPersistent(env);
563
564 env.Reset();
565
566 FileByteSink startup_sink(startup_name.start());
567 StartupSerializer startup_serializer(isolate, &startup_sink);
568 startup_serializer.SerializeStrongReferences();
569
570 FileByteSink partial_sink(FLAG_testing_serialization_file);
571 PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink);
572 p_ser.Serialize(&raw_context);
573 startup_serializer.SerializeWeakReferences();
574
575 partial_sink.WriteSpaceUsed(
576 p_ser.CurrentAllocationAddress(NEW_SPACE),
577 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE),
578 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE),
579 p_ser.CurrentAllocationAddress(CODE_SPACE),
580 p_ser.CurrentAllocationAddress(MAP_SPACE),
581 p_ser.CurrentAllocationAddress(CELL_SPACE),
582 p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
583
584 startup_sink.WriteSpaceUsed(
585 startup_serializer.CurrentAllocationAddress(NEW_SPACE),
586 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE),
587 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE),
588 startup_serializer.CurrentAllocationAddress(CODE_SPACE),
589 startup_serializer.CurrentAllocationAddress(MAP_SPACE),
590 startup_serializer.CurrentAllocationAddress(CELL_SPACE),
591 startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE));
592 startup_name.Dispose();
593 }
594 v8_isolate->Dispose();
595 }
596 }
597
598
599 UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
499 if (!Snapshot::HaveASnapshotToStartFrom()) { 600 if (!Snapshot::HaveASnapshotToStartFrom()) {
500 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 601 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
501 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 602 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
502 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 603 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
503 604
504 CHECK(InitializeFromFile(startup_name.start())); 605 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
606 CHECK(v8_isolate);
505 startup_name.Dispose(); 607 startup_name.Dispose();
506 608 {
507 const char* file_name = FLAG_testing_serialization_file; 609 v8::Isolate::Scope isolate_scope(v8_isolate);
508 610
509 int snapshot_size = 0; 611 const char* file_name = FLAG_testing_serialization_file;
510 byte* snapshot = ReadBytes(file_name, &snapshot_size); 612
511 613 int snapshot_size = 0;
512 Isolate* isolate = CcTest::i_isolate(); 614 byte* snapshot = ReadBytes(file_name, &snapshot_size);
513 Object* root; 615
514 { 616 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
515 SnapshotByteSource source(snapshot, snapshot_size); 617 Object* root;
516 Deserializer deserializer(&source); 618 {
517 ReserveSpaceForSnapshot(&deserializer, file_name); 619 SnapshotByteSource source(snapshot, snapshot_size);
518 deserializer.DeserializePartial(isolate, &root); 620 Deserializer deserializer(&source);
519 CHECK(root->IsString()); 621 ReserveSpaceForSnapshot(&deserializer, file_name);
520 } 622 deserializer.DeserializePartial(isolate, &root);
521 HandleScope handle_scope(isolate); 623 CHECK(root->IsContext());
522 Handle<Object> root_handle(root, isolate); 624 }
523 625 HandleScope handle_scope(isolate);
524 626 Handle<Object> root_handle(root, isolate);
525 Object* root2; 627
526 { 628
527 SnapshotByteSource source(snapshot, snapshot_size); 629 Object* root2;
528 Deserializer deserializer(&source); 630 {
529 ReserveSpaceForSnapshot(&deserializer, file_name); 631 SnapshotByteSource source(snapshot, snapshot_size);
530 deserializer.DeserializePartial(isolate, &root2); 632 Deserializer deserializer(&source);
531 CHECK(root2->IsString()); 633 ReserveSpaceForSnapshot(&deserializer, file_name);
532 CHECK(*root_handle == root2); 634 deserializer.DeserializePartial(isolate, &root2);
533 } 635 CHECK(root2->IsContext());
534 } 636 CHECK(*root_handle != root2);
535 } 637 }
536 638 }
537 639 v8_isolate->Dispose();
538 TEST(ContextSerialization) { 640 }
539 if (!Snapshot::HaveASnapshotToStartFrom()) { 641 }
540 Isolate* isolate = CcTest::i_isolate(); 642
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 643
650 TEST(TestThatAlwaysSucceeds) { 644 TEST(TestThatAlwaysSucceeds) {
651 } 645 }
652 646
653 647
654 TEST(TestThatAlwaysFails) { 648 TEST(TestThatAlwaysFails) {
655 bool ArtificialFailure = false; 649 bool ArtificialFailure = false;
656 CHECK(ArtificialFailure); 650 CHECK(ArtificialFailure);
657 } 651 }
658 652
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 } 786 }
793 787
794 788
795 TEST(SerializeToplevelIsolates) { 789 TEST(SerializeToplevelIsolates) {
796 FLAG_serialize_toplevel = true; 790 FLAG_serialize_toplevel = true;
797 791
798 const char* source = "function f() { return 'abc'; }; f() + 'def'"; 792 const char* source = "function f() { return 'abc'; }; f() + 'def'";
799 v8::ScriptCompiler::CachedData* cache; 793 v8::ScriptCompiler::CachedData* cache;
800 794
801 v8::Isolate* isolate1 = v8::Isolate::New(); 795 v8::Isolate* isolate1 = v8::Isolate::New();
802 v8::Isolate* isolate2 = v8::Isolate::New();
803 { 796 {
804 v8::Isolate::Scope iscope(isolate1); 797 v8::Isolate::Scope iscope(isolate1);
805 v8::HandleScope scope(isolate1); 798 v8::HandleScope scope(isolate1);
806 v8::Local<v8::Context> context = v8::Context::New(isolate1); 799 v8::Local<v8::Context> context = v8::Context::New(isolate1);
807 v8::Context::Scope context_scope(context); 800 v8::Context::Scope context_scope(context);
808 801
809 v8::Local<v8::String> source_str = v8_str(source); 802 v8::Local<v8::String> source_str = v8_str(source);
810 v8::ScriptOrigin origin(v8_str("test")); 803 v8::ScriptOrigin origin(v8_str("test"));
811 v8::ScriptCompiler::Source source(source_str, origin); 804 v8::ScriptCompiler::Source source(source_str, origin);
812 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound( 805 v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
813 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache); 806 isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
814 const v8::ScriptCompiler::CachedData* data = source.GetCachedData(); 807 const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
815 // Persist cached data. 808 // Persist cached data.
816 uint8_t* buffer = NewArray<uint8_t>(data->length); 809 uint8_t* buffer = NewArray<uint8_t>(data->length);
817 MemCopy(buffer, data->data, data->length); 810 MemCopy(buffer, data->data, data->length);
818 cache = new v8::ScriptCompiler::CachedData( 811 cache = new v8::ScriptCompiler::CachedData(
819 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned); 812 buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
820 813
821 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 814 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
822 CHECK(result->ToString()->Equals(v8_str("abcdef"))); 815 CHECK(result->ToString()->Equals(v8_str("abcdef")));
823 } 816 }
824 isolate1->Dispose(); 817 isolate1->Dispose();
825 818
819 v8::Isolate* isolate2 = v8::Isolate::New();
826 { 820 {
827 v8::Isolate::Scope iscope(isolate2); 821 v8::Isolate::Scope iscope(isolate2);
828 v8::HandleScope scope(isolate2); 822 v8::HandleScope scope(isolate2);
829 v8::Local<v8::Context> context = v8::Context::New(isolate2); 823 v8::Local<v8::Context> context = v8::Context::New(isolate2);
830 v8::Context::Scope context_scope(context); 824 v8::Context::Scope context_scope(context);
831 825
832 v8::Local<v8::String> source_str = v8_str(source); 826 v8::Local<v8::String> source_str = v8_str(source);
833 v8::ScriptOrigin origin(v8_str("test")); 827 v8::ScriptOrigin origin(v8_str("test"));
834 v8::ScriptCompiler::Source source(source_str, origin, cache); 828 v8::ScriptCompiler::Source source(source_str, origin, cache);
835 v8::Local<v8::UnboundScript> script; 829 v8::Local<v8::UnboundScript> script;
836 { 830 {
837 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 831 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
838 script = v8::ScriptCompiler::CompileUnbound( 832 script = v8::ScriptCompiler::CompileUnbound(
839 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 833 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
840 } 834 }
841 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 835 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
842 CHECK(result->ToString()->Equals(v8_str("abcdef"))); 836 CHECK(result->ToString()->Equals(v8_str("abcdef")));
843 } 837 }
844 isolate2->Dispose(); 838 isolate2->Dispose();
845 } 839 }
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