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

Side by Side Diff: src/api.cc

Issue 991803002: Do not include cached code in the start-up snapshot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test case Created 5 years, 9 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
« no previous file with comments | « no previous file | test/cctest/test-heap-profiler.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); 352 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>"));
353 ScriptCompiler::Source source(source_string, origin); 353 ScriptCompiler::Source source(source_string, origin);
354 Local<Script> script = ScriptCompiler::Compile(isolate, &source); 354 Local<Script> script = ScriptCompiler::Compile(isolate, &source);
355 if (try_catch.HasCaught()) return false; 355 if (try_catch.HasCaught()) return false;
356 script->Run(); 356 script->Run();
357 return !try_catch.HasCaught(); 357 return !try_catch.HasCaught();
358 } 358 }
359 359
360 360
361 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) { 361 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) {
362 i::Isolate* internal_isolate = new i::Isolate(true); 362 i::Isolate* i_isolate = new i::Isolate(true);
363 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate); 363 Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate);
364 StartupData result = {NULL, 0}; 364 StartupData result = {NULL, 0};
365 { 365 {
366 Isolate::Scope isolate_scope(isolate); 366 Isolate::Scope isolate_scope(isolate);
367 internal_isolate->Init(NULL); 367 i_isolate->Init(NULL);
368 Persistent<Context> context; 368 Persistent<Context> context;
369 i::Snapshot::Metadata metadata; 369 i::Snapshot::Metadata metadata;
370 { 370 {
371 HandleScope handle_scope(isolate); 371 HandleScope handle_scope(isolate);
372 Handle<Context> new_context = Context::New(isolate); 372 Handle<Context> new_context = Context::New(isolate);
373 context.Reset(isolate, new_context); 373 context.Reset(isolate, new_context);
374 if (custom_source != NULL) { 374 if (custom_source != NULL) {
375 metadata.set_embeds_script(true); 375 metadata.set_embeds_script(true);
376 Context::Scope context_scope(new_context); 376 Context::Scope context_scope(new_context);
377 if (!RunExtraCode(isolate, custom_source)) context.Reset(); 377 if (!RunExtraCode(isolate, custom_source)) context.Reset();
378 } 378 }
379 } 379 }
380 if (!context.IsEmpty()) { 380 if (!context.IsEmpty()) {
381 // Make sure all builtin scripts are cached. 381 // Make sure all builtin scripts are cached.
382 { 382 {
383 HandleScope scope(isolate); 383 HandleScope scope(isolate);
384 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { 384 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
385 internal_isolate->bootstrapper()->NativesSourceLookup(i); 385 i_isolate->bootstrapper()->NativesSourceLookup(i);
386 } 386 }
387 } 387 }
388 // If we don't do this then we end up with a stray root pointing at the 388 // If we don't do this then we end up with a stray root pointing at the
389 // context even after we have disposed of the context. 389 // context even after we have disposed of the context.
390 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); 390 i_isolate->heap()->CollectAllAvailableGarbage("mksnapshot");
391
392 {
393 HandleScope scope(isolate);
394 // Clear code caches.
395 i_isolate->heap()->public_set_code_stubs(
396 *i::UnseededNumberDictionary::New(i_isolate, 128, i::TENURED));
Toon Verwaest 2015/03/09 12:32:50 What about extracting the original constructor fro
397 i_isolate->heap()->public_set_non_monomorphic_cache(
398 *i::UnseededNumberDictionary::New(i_isolate, 64, i::TENURED));
399 }
400
391 i::Object* raw_context = *v8::Utils::OpenPersistent(context); 401 i::Object* raw_context = *v8::Utils::OpenPersistent(context);
392 context.Reset(); 402 context.Reset();
393 403
394 i::SnapshotByteSink snapshot_sink; 404 i::SnapshotByteSink snapshot_sink;
395 i::StartupSerializer ser(internal_isolate, &snapshot_sink); 405 i::StartupSerializer ser(i_isolate, &snapshot_sink);
396 ser.SerializeStrongReferences(); 406 ser.SerializeStrongReferences();
397 407
398 i::SnapshotByteSink context_sink; 408 i::SnapshotByteSink context_sink;
399 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink); 409 i::PartialSerializer context_ser(i_isolate, &ser, &context_sink);
400 context_ser.Serialize(&raw_context); 410 context_ser.Serialize(&raw_context);
401 ser.SerializeWeakReferences(); 411 ser.SerializeWeakReferences();
402 412
403 result = i::Snapshot::CreateSnapshotBlob(ser, context_ser, metadata); 413 result = i::Snapshot::CreateSnapshotBlob(ser, context_ser, metadata);
404 } 414 }
405 } 415 }
406 isolate->Dispose(); 416 isolate->Dispose();
407 return result; 417 return result;
408 } 418 }
409 419
(...skipping 7588 matching lines...) Expand 10 before | Expand all | Expand 10 after
7998 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8008 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7999 Address callback_address = 8009 Address callback_address =
8000 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8010 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8001 VMState<EXTERNAL> state(isolate); 8011 VMState<EXTERNAL> state(isolate);
8002 ExternalCallbackScope call_scope(isolate, callback_address); 8012 ExternalCallbackScope call_scope(isolate, callback_address);
8003 callback(info); 8013 callback(info);
8004 } 8014 }
8005 8015
8006 8016
8007 } } // namespace v8::internal 8017 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698