Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index b2dba5a4c7fcef7c894f80b7a774224e6e195f27..21ad9435c26ae2340c71840786e981053ab34de9 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -641,6 +641,12 @@ void Object::RegisterPrivateClass(const Class& cls, |
| return error.raw(); \ |
| } \ |
| +#define PATCH_LIBRARY(lib, raw_patch_script) \ |
| + patch_script ^= raw_patch_script; \ |
| + error = lib.Patch(patch_script); \ |
| + if (!error.IsNull()) { \ |
| + return error.raw(); \ |
| + } \ |
|
siva
2013/02/22 18:25:39
Could you leave this the way it was without a macr
|
| RawError* Object::Init(Isolate* isolate) { |
| TIMERSCOPE(time_bootstrap); |
| @@ -1005,11 +1011,9 @@ RawError* Object::Init(Isolate* isolate) { |
| if (!error.IsNull()) { |
| return error.raw(); |
| } |
| - Script& patch_script = Script::Handle(Bootstrap::LoadCoreScript(true)); |
| - error = core_lib.Patch(patch_script); |
| - if (!error.IsNull()) { |
| - return error.raw(); |
| - } |
| + Script& patch_script = Script::Handle(); |
| + PATCH_LIBRARY(core_lib, Bootstrap::LoadCoreScript(true)); |
| + |
| Library::InitASyncLibrary(isolate); |
| const Script& async_script = |
| Script::Handle(Bootstrap::LoadASyncScript(false)); |
| @@ -1019,11 +1023,8 @@ RawError* Object::Init(Isolate* isolate) { |
| if (!error.IsNull()) { |
| return error.raw(); |
| } |
| - patch_script = Bootstrap::LoadASyncScript(true); |
| - error = async_lib.Patch(patch_script); |
| - if (!error.IsNull()) { |
| - return error.raw(); |
| - } |
| + PATCH_LIBRARY(async_lib, Bootstrap::LoadASyncScript(true)); |
| + |
| const Script& collection_script = |
| Script::Handle(Bootstrap::LoadCollectionScript(false)); |
| const Library& collection_lib = |
| @@ -1049,11 +1050,8 @@ RawError* Object::Init(Isolate* isolate) { |
| if (!error.IsNull()) { |
| return error.raw(); |
| } |
| - patch_script = Bootstrap::LoadMathScript(true); |
| - error = math_lib.Patch(patch_script); |
| - if (!error.IsNull()) { |
| - return error.raw(); |
| - } |
| + PATCH_LIBRARY(math_lib, Bootstrap::LoadMathScript(true)); |
| + |
| const Script& isolate_script = Script::Handle( |
| Bootstrap::LoadIsolateScript(false)); |
| Library::InitIsolateLibrary(isolate); |
| @@ -1063,11 +1061,8 @@ RawError* Object::Init(Isolate* isolate) { |
| if (!error.IsNull()) { |
| return error.raw(); |
| } |
| - patch_script = Bootstrap::LoadIsolateScript(true); |
| - error = isolate_lib.Patch(patch_script); |
| - if (!error.IsNull()) { |
| - return error.raw(); |
| - } |
| + PATCH_LIBRARY(isolate_lib, Bootstrap::LoadIsolateScript(true)); |
| + |
| const Script& mirrors_script = Script::Handle( |
| Bootstrap::LoadMirrorsScript(false)); |
| Library::InitMirrorsLibrary(isolate); |
| @@ -1077,11 +1072,8 @@ RawError* Object::Init(Isolate* isolate) { |
| if (!error.IsNull()) { |
| return error.raw(); |
| } |
| - patch_script = Bootstrap::LoadMirrorsScript(true); |
| - error = mirrors_lib.Patch(patch_script); |
| - if (!error.IsNull()) { |
| - return error.raw(); |
| - } |
| + PATCH_LIBRARY(mirrors_lib, Bootstrap::LoadMirrorsScript(true)); |
| + |
| const Script& scalarlist_script = Script::Handle( |
| Bootstrap::LoadScalarlistScript(false)); |
| ASSERT(!scalarlist_lib.IsNull()); |
| @@ -1089,11 +1081,8 @@ RawError* Object::Init(Isolate* isolate) { |
| if (!error.IsNull()) { |
| return error.raw(); |
| } |
| - patch_script = Bootstrap::LoadScalarlistScript(true); |
| - error = scalarlist_lib.Patch(patch_script); |
| - if (!error.IsNull()) { |
| - return error.raw(); |
| - } |
| + PATCH_LIBRARY(scalarlist_lib, Bootstrap::LoadScalarlistScript(true)); |
| + |
| Library& lib = Library::Handle(); |
| INIT_LIBRARY(Crypto, |
| Bootstrap::LoadCryptoScript(false), |
| @@ -1101,6 +1090,7 @@ RawError* Object::Init(Isolate* isolate) { |
| INIT_LIBRARY(Json, |
| Bootstrap::LoadJsonScript(false), |
| Library::JsonLibrary()); |
| + PATCH_LIBRARY(lib, Bootstrap::LoadJsonScript(true)); |
|
siva
2013/02/22 18:25:39
Just add the patch code inline here.
|
| INIT_LIBRARY(Utf, |
| Bootstrap::LoadUtfScript(false), |
| Library::UtfLibrary()); |