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

Side by Side Diff: src/api.cc

Issue 1289603002: Put V8 extras into the snapshot (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment Created 5 years, 4 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 | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 HandleScope handle_scope(isolate); 376 HandleScope handle_scope(isolate);
377 Local<Context> new_context = Context::New(isolate); 377 Local<Context> new_context = Context::New(isolate);
378 context.Reset(isolate, new_context); 378 context.Reset(isolate, new_context);
379 if (custom_source != NULL) { 379 if (custom_source != NULL) {
380 metadata.set_embeds_script(true); 380 metadata.set_embeds_script(true);
381 Context::Scope context_scope(new_context); 381 Context::Scope context_scope(new_context);
382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); 382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset();
383 } 383 }
384 } 384 }
385 if (!context.IsEmpty()) { 385 if (!context.IsEmpty()) {
386 // Make sure all builtin scripts are cached.
387 { 386 {
388 HandleScope scope(isolate); 387 HandleScope scope(isolate);
388
389 // Make sure all builtin scripts are cached.
389 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { 390 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
390 internal_isolate->bootstrapper()->SourceLookup<i::Natives>(i); 391 internal_isolate->bootstrapper()->SourceLookup<i::Natives>(i);
391 } 392 }
393
394 // Make sure all extra scripts are cached.
395 for (int i = 0; i < i::ExtraNatives::GetBuiltinsCount(); i++) {
396 internal_isolate->bootstrapper()->SourceLookup<i::ExtraNatives>(i);
397 }
Yang 2015/08/13 12:28:24 I don't think any of this is actually necessary. W
392 } 398 }
393 // If we don't do this then we end up with a stray root pointing at the 399 // If we don't do this then we end up with a stray root pointing at the
394 // context even after we have disposed of the context. 400 // context even after we have disposed of the context.
395 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot"); 401 internal_isolate->heap()->CollectAllAvailableGarbage("mksnapshot");
396 i::Object* raw_context = *v8::Utils::OpenPersistent(context); 402 i::Object* raw_context = *v8::Utils::OpenPersistent(context);
397 context.Reset(); 403 context.Reset();
398 404
399 i::SnapshotByteSink snapshot_sink; 405 i::SnapshotByteSink snapshot_sink;
400 i::StartupSerializer ser(internal_isolate, &snapshot_sink); 406 i::StartupSerializer ser(internal_isolate, &snapshot_sink);
401 ser.SerializeStrongReferences(); 407 ser.SerializeStrongReferences();
(...skipping 8016 matching lines...) Expand 10 before | Expand all | Expand 10 after
8418 Address callback_address = 8424 Address callback_address =
8419 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8425 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8420 VMState<EXTERNAL> state(isolate); 8426 VMState<EXTERNAL> state(isolate);
8421 ExternalCallbackScope call_scope(isolate, callback_address); 8427 ExternalCallbackScope call_scope(isolate, callback_address);
8422 callback(info); 8428 callback(info);
8423 } 8429 }
8424 8430
8425 8431
8426 } // namespace internal 8432 } // namespace internal
8427 } // namespace v8 8433 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698