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

Side by Side Diff: src/api.cc

Issue 848023002: Store embed-script flag as metadata into snapshot blob. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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/snapshot-external.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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 StartupData V8::CreateSnapshotDataBlob(char* custom_source) { 223 StartupData V8::CreateSnapshotDataBlob(char* custom_source) {
224 Isolate::CreateParams params; 224 Isolate::CreateParams params;
225 params.enable_serializer = true; 225 params.enable_serializer = true;
226 Isolate* isolate = v8::Isolate::New(params); 226 Isolate* isolate = v8::Isolate::New(params);
227 StartupData result = {NULL, 0}; 227 StartupData result = {NULL, 0};
228 { 228 {
229 Isolate::Scope isolate_scope(isolate); 229 Isolate::Scope isolate_scope(isolate);
230 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 230 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
231 Persistent<Context> context; 231 Persistent<Context> context;
232 i::Snapshot::Metadata metadata;
232 { 233 {
233 HandleScope handle_scope(isolate); 234 HandleScope handle_scope(isolate);
234 Handle<Context> new_context = Context::New(isolate); 235 Handle<Context> new_context = Context::New(isolate);
235 context.Reset(isolate, new_context); 236 context.Reset(isolate, new_context);
236 if (custom_source != NULL) { 237 if (custom_source != NULL) {
238 metadata.set_embeds_script(true);
237 Context::Scope context_scope(new_context); 239 Context::Scope context_scope(new_context);
238 if (!RunExtraCode(isolate, custom_source)) context.Reset(); 240 if (!RunExtraCode(isolate, custom_source)) context.Reset();
239 } 241 }
240 } 242 }
241 if (!context.IsEmpty()) { 243 if (!context.IsEmpty()) {
242 // Make sure all builtin scripts are cached. 244 // Make sure all builtin scripts are cached.
243 { 245 {
244 HandleScope scope(isolate); 246 HandleScope scope(isolate);
245 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { 247 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
246 internal_isolate->bootstrapper()->NativesSourceLookup(i); 248 internal_isolate->bootstrapper()->NativesSourceLookup(i);
(...skipping 10 matching lines...) Expand all
257 ser.SerializeStrongReferences(); 259 ser.SerializeStrongReferences();
258 260
259 i::SnapshotByteSink context_sink; 261 i::SnapshotByteSink context_sink;
260 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink); 262 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink);
261 context_ser.Serialize(&raw_context); 263 context_ser.Serialize(&raw_context);
262 ser.SerializeWeakReferences(); 264 ser.SerializeWeakReferences();
263 265
264 i::SnapshotData sd(snapshot_sink, ser); 266 i::SnapshotData sd(snapshot_sink, ser);
265 i::SnapshotData csd(context_sink, context_ser); 267 i::SnapshotData csd(context_sink, context_ser);
266 268
267 result = i::Snapshot::CreateSnapshotBlob(sd.RawData(), csd.RawData()); 269 result = i::Snapshot::CreateSnapshotBlob(sd.RawData(), csd.RawData(),
270 metadata);
268 } 271 }
269 } 272 }
270 isolate->Dispose(); 273 isolate->Dispose();
271 return result; 274 return result;
272 } 275 }
273 276
274 277
275 void V8::SetFlagsFromString(const char* str, int length) { 278 void V8::SetFlagsFromString(const char* str, int length) {
276 i::FlagList::SetFlagsFromString(str, length); 279 i::FlagList::SetFlagsFromString(str, length);
277 } 280 }
(...skipping 7353 matching lines...) Expand 10 before | Expand all | Expand 10 after
7631 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7634 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7632 Address callback_address = 7635 Address callback_address =
7633 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7636 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7634 VMState<EXTERNAL> state(isolate); 7637 VMState<EXTERNAL> state(isolate);
7635 ExternalCallbackScope call_scope(isolate, callback_address); 7638 ExternalCallbackScope call_scope(isolate, callback_address);
7636 callback(info); 7639 callback(info);
7637 } 7640 }
7638 7641
7639 7642
7640 } } // namespace v8::internal 7643 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/snapshot-external.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698