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

Side by Side Diff: src/api.cc

Issue 1000063002: Hide RegExp and String initialization in a closure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments 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 | src/i18n.js » ('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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 321 }
322 322
323 323
324 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { 324 void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) {
325 i::V8::SetSnapshotBlob(snapshot_blob); 325 i::V8::SetSnapshotBlob(snapshot_blob);
326 } 326 }
327 327
328 328
329 bool RunExtraCode(Isolate* isolate, const char* utf8_source) { 329 bool RunExtraCode(Isolate* isolate, const char* utf8_source) {
330 // Run custom script if provided. 330 // Run custom script if provided.
331 base::ElapsedTimer timer;
332 timer.Start();
331 TryCatch try_catch; 333 TryCatch try_catch;
332 Local<String> source_string = String::NewFromUtf8(isolate, utf8_source); 334 Local<String> source_string = String::NewFromUtf8(isolate, utf8_source);
333 if (try_catch.HasCaught()) return false; 335 if (try_catch.HasCaught()) return false;
334 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); 336 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>"));
335 ScriptCompiler::Source source(source_string, origin); 337 ScriptCompiler::Source source(source_string, origin);
336 Local<Script> script = ScriptCompiler::Compile(isolate, &source); 338 Local<Script> script = ScriptCompiler::Compile(isolate, &source);
337 if (try_catch.HasCaught()) return false; 339 if (try_catch.HasCaught()) return false;
338 script->Run(); 340 script->Run();
341 if (i::FLAG_profile_deserialization) {
342 i::PrintF("Executing custom snapshot script took %0.3f ms\n",
343 timer.Elapsed().InMillisecondsF());
344 }
345 timer.Stop();
339 return !try_catch.HasCaught(); 346 return !try_catch.HasCaught();
340 } 347 }
341 348
342 349
343 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) { 350 StartupData V8::CreateSnapshotDataBlob(const char* custom_source) {
344 i::Isolate* internal_isolate = new i::Isolate(true); 351 i::Isolate* internal_isolate = new i::Isolate(true);
345 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate); 352 Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate);
346 StartupData result = {NULL, 0}; 353 StartupData result = {NULL, 0};
347 { 354 {
355 base::ElapsedTimer timer;
356 timer.Start();
348 Isolate::Scope isolate_scope(isolate); 357 Isolate::Scope isolate_scope(isolate);
349 internal_isolate->Init(NULL); 358 internal_isolate->Init(NULL);
350 Persistent<Context> context; 359 Persistent<Context> context;
351 i::Snapshot::Metadata metadata; 360 i::Snapshot::Metadata metadata;
352 { 361 {
353 HandleScope handle_scope(isolate); 362 HandleScope handle_scope(isolate);
354 Handle<Context> new_context = Context::New(isolate); 363 Handle<Context> new_context = Context::New(isolate);
355 context.Reset(isolate, new_context); 364 context.Reset(isolate, new_context);
356 if (custom_source != NULL) { 365 if (custom_source != NULL) {
357 metadata.set_embeds_script(true); 366 metadata.set_embeds_script(true);
(...skipping 19 matching lines...) Expand all
377 i::StartupSerializer ser(internal_isolate, &snapshot_sink); 386 i::StartupSerializer ser(internal_isolate, &snapshot_sink);
378 ser.SerializeStrongReferences(); 387 ser.SerializeStrongReferences();
379 388
380 i::SnapshotByteSink context_sink; 389 i::SnapshotByteSink context_sink;
381 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink); 390 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink);
382 context_ser.Serialize(&raw_context); 391 context_ser.Serialize(&raw_context);
383 ser.SerializeWeakReferences(); 392 ser.SerializeWeakReferences();
384 393
385 result = i::Snapshot::CreateSnapshotBlob(ser, context_ser, metadata); 394 result = i::Snapshot::CreateSnapshotBlob(ser, context_ser, metadata);
386 } 395 }
396 if (i::FLAG_profile_deserialization) {
397 i::PrintF("Creating snapshot took %0.3f ms\n",
398 timer.Elapsed().InMillisecondsF());
399 }
400 timer.Stop();
387 } 401 }
388 isolate->Dispose(); 402 isolate->Dispose();
389 return result; 403 return result;
390 } 404 }
391 405
392 406
393 void V8::SetFlagsFromString(const char* str, int length) { 407 void V8::SetFlagsFromString(const char* str, int length) {
394 i::FlagList::SetFlagsFromString(str, length); 408 i::FlagList::SetFlagsFromString(str, length);
395 } 409 }
396 410
(...skipping 7579 matching lines...) Expand 10 before | Expand all | Expand 10 after
7976 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7990 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7977 Address callback_address = 7991 Address callback_address =
7978 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7992 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7979 VMState<EXTERNAL> state(isolate); 7993 VMState<EXTERNAL> state(isolate);
7980 ExternalCallbackScope call_scope(isolate, callback_address); 7994 ExternalCallbackScope call_scope(isolate, callback_address);
7981 callback(info); 7995 callback(info);
7982 } 7996 }
7983 7997
7984 7998
7985 } } // namespace v8::internal 7999 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/i18n.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698