Load deferred classes eagerly when generating script snapshots
BUG= R=asiva@google.com Review URL: https://codereview.chromium.org//1155183003
This commit is contained in:
@@ -516,7 +516,8 @@ static void SetupForGenericSnapshotCreation() {
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
CommandLineOptions vm_options(argc);
|
||||
const int EXTRA_VM_ARGUMENTS = 1;
|
||||
CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
|
||||
|
||||
// Initialize the URL mapping array.
|
||||
CommandLineOptions url_mapping_array(argc);
|
||||
@@ -534,6 +535,8 @@ int main(int argc, char** argv) {
|
||||
Thread::InitOnce();
|
||||
DartUtils::SetOriginalWorkingDirectory();
|
||||
|
||||
vm_options.AddArgument("--load_deferred_eagerly");
|
||||
|
||||
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
|
||||
|
||||
// Initialize the Dart VM.
|
||||
|
||||
+6
-1
@@ -872,7 +872,8 @@ static const char* ServiceRequestHandler(
|
||||
|
||||
void main(int argc, char** argv) {
|
||||
char* script_name;
|
||||
CommandLineOptions vm_options(argc);
|
||||
const int EXTRA_VM_ARGUMENTS = 2;
|
||||
CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
|
||||
CommandLineOptions dart_options(argc);
|
||||
bool print_flags_seen = false;
|
||||
bool verbose_debug_seen = false;
|
||||
@@ -921,6 +922,10 @@ void main(int argc, char** argv) {
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
|
||||
if (generate_script_snapshot) {
|
||||
vm_options.AddArgument("--load_deferred_eagerly");
|
||||
}
|
||||
|
||||
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
|
||||
|
||||
// Start event handler.
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
namespace dart {
|
||||
|
||||
DECLARE_FLAG(bool, load_deferred_eagerly);
|
||||
DECLARE_FLAG(bool, print_class_table);
|
||||
DECLARE_FLAG(bool, verify_handles);
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
@@ -1429,6 +1430,7 @@ DART_EXPORT Dart_Handle Dart_CreateSnapshot(
|
||||
intptr_t* vm_isolate_snapshot_size,
|
||||
uint8_t** isolate_snapshot_buffer,
|
||||
intptr_t* isolate_snapshot_size) {
|
||||
ASSERT(FLAG_load_deferred_eagerly);
|
||||
Isolate* isolate = Isolate::Current();
|
||||
DARTSCOPE(isolate);
|
||||
TIMERSCOPE(isolate, time_creating_snapshot);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
namespace dart {
|
||||
|
||||
DECLARE_FLAG(bool, enable_type_checks);
|
||||
DECLARE_FLAG(bool, load_deferred_eagerly);
|
||||
|
||||
// Check if serialized and deserialized objects are equal.
|
||||
static bool Equals(const Object& expected, const Object& actual) {
|
||||
@@ -1232,6 +1233,9 @@ UNIT_TEST_CASE(ScriptSnapshot) {
|
||||
intptr_t expected_num_libs;
|
||||
intptr_t actual_num_libs;
|
||||
|
||||
bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly;
|
||||
FLAG_load_deferred_eagerly = true;
|
||||
|
||||
{
|
||||
// Start an Isolate, and create a full snapshot of it.
|
||||
TestIsolateScope __test_isolate__;
|
||||
@@ -1248,6 +1252,7 @@ UNIT_TEST_CASE(ScriptSnapshot) {
|
||||
Dart_ExitScope();
|
||||
}
|
||||
|
||||
FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode;
|
||||
{
|
||||
// Create an Isolate using the full snapshot, load a script and create
|
||||
// a script snapshot of the script.
|
||||
@@ -1328,6 +1333,8 @@ UNIT_TEST_CASE(ScriptSnapshot1) {
|
||||
uint8_t* full_snapshot = NULL;
|
||||
uint8_t* script_snapshot = NULL;
|
||||
|
||||
bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly;
|
||||
FLAG_load_deferred_eagerly = true;
|
||||
{
|
||||
// Start an Isolate, and create a full snapshot of it.
|
||||
TestIsolateScope __test_isolate__;
|
||||
@@ -1373,6 +1380,8 @@ UNIT_TEST_CASE(ScriptSnapshot1) {
|
||||
result = Dart_LoadScriptFromSnapshot(script_snapshot, size);
|
||||
EXPECT_VALID(result);
|
||||
}
|
||||
|
||||
FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode;
|
||||
Dart_ShutdownIsolate();
|
||||
free(full_snapshot);
|
||||
free(script_snapshot);
|
||||
@@ -1412,8 +1421,10 @@ UNIT_TEST_CASE(ScriptSnapshot2) {
|
||||
uint8_t* script_snapshot = NULL;
|
||||
|
||||
// Force creation of snapshot in production mode.
|
||||
bool saved_mode = FLAG_enable_type_checks;
|
||||
bool saved_enable_type_checks_mode = FLAG_enable_type_checks;
|
||||
FLAG_enable_type_checks = false;
|
||||
bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly;
|
||||
FLAG_load_deferred_eagerly = true;
|
||||
|
||||
{
|
||||
// Start an Isolate, and create a full snapshot of it.
|
||||
@@ -1461,7 +1472,8 @@ UNIT_TEST_CASE(ScriptSnapshot2) {
|
||||
}
|
||||
|
||||
// Continue in originally saved mode.
|
||||
FLAG_enable_type_checks = saved_mode;
|
||||
FLAG_enable_type_checks = saved_enable_type_checks_mode;
|
||||
FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode;
|
||||
|
||||
{
|
||||
// Now Create an Isolate using the full snapshot and load the
|
||||
@@ -1476,15 +1488,15 @@ UNIT_TEST_CASE(ScriptSnapshot2) {
|
||||
|
||||
// Invoke the test_s function.
|
||||
result = Dart_Invoke(lib, NewString("test_s"), 0, NULL);
|
||||
EXPECT(Dart_IsError(result) == saved_mode);
|
||||
EXPECT(Dart_IsError(result) == saved_enable_type_checks_mode);
|
||||
|
||||
// Invoke the test_i function.
|
||||
result = Dart_Invoke(lib, NewString("test_i"), 0, NULL);
|
||||
EXPECT(Dart_IsError(result) == saved_mode);
|
||||
EXPECT(Dart_IsError(result) == saved_enable_type_checks_mode);
|
||||
|
||||
// Invoke the test_b function.
|
||||
result = Dart_Invoke(lib, NewString("test_b"), 0, NULL);
|
||||
EXPECT(Dart_IsError(result) == saved_mode);
|
||||
EXPECT(Dart_IsError(result) == saved_enable_type_checks_mode);
|
||||
}
|
||||
Dart_ShutdownIsolate();
|
||||
free(full_snapshot);
|
||||
|
||||
Reference in New Issue
Block a user