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

Unified Diff: src/handles.cc

Issue 93066: Built-in JSON support (Closed)
Patch Set: Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index 99161ce7338c90dd5e6673428773f40b7e81d976..2ef9e8591a11440c63b941a1576bde6b408abccf 100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -627,9 +627,9 @@ OptimizedObjectForAddingMultipleProperties::
}
-void LoadLazy(Handle<JSFunction> fun, bool* pending_exception) {
+void LoadLazy(Handle<JSObject> obj, bool* pending_exception) {
HandleScope scope;
- Handle<FixedArray> info(FixedArray::cast(fun->shared()->lazy_load_data()));
+ Handle<FixedArray> info(FixedArray::cast(obj->map()->constructor()));
int index = Smi::cast(info->get(0))->value();
ASSERT(index >= 0);
Handle<Context> compile_context(Context::cast(info->get(1)));
@@ -674,7 +674,8 @@ void LoadLazy(Handle<JSFunction> fun, bool* pending_exception) {
// Reset the lazy load data before running the script to make sure
// not to get recursive lazy loading.
- fun->shared()->set_lazy_load_data(Heap::undefined_value());
+ obj->map()->set_needs_loading(false);
+ obj->map()->set_constructor(info->get(3));
// Run the script.
Handle<JSFunction> script_fun(
@@ -682,19 +683,30 @@ void LoadLazy(Handle<JSFunction> fun, bool* pending_exception) {
Execution::Call(script_fun, receiver, 0, NULL, pending_exception);
// If lazy loading failed, restore the unloaded state of fun.
Mads Ager (chromium) 2009/04/23 19:09:25 fun -> obj
- if (*pending_exception) fun->shared()->set_lazy_load_data(*info);
+ if (*pending_exception) {
+ obj->map()->set_needs_loading(true);
+ obj->map()->set_constructor(*info);
+ }
}
-void SetupLazy(Handle<JSFunction> fun,
+void SetupLazy(Handle<JSObject> obj,
int index,
Handle<Context> compile_context,
Handle<Context> function_context) {
- Handle<FixedArray> arr = Factory::NewFixedArray(3);
+ Handle<FixedArray> arr = Factory::NewFixedArray(4);
arr->set(0, Smi::FromInt(index));
arr->set(1, *compile_context); // Compile in this context
arr->set(2, *function_context); // Set function context to this
- fun->shared()->set_lazy_load_data(*arr);
+ arr->set(3, obj->map()->constructor()); // Remember the constructor
+ Handle<Map> old_map(obj->map());
+ Handle<Map> new_map = Factory::CopyMap(old_map);
+ obj->set_map(*new_map);
+ new_map->set_needs_loading(true);
+ // Store the lazy loading info in the constructor field. We'll
+ // reestablish the constructor from the fixed array after loading.
+ new_map->set_constructor(*arr);
+ ASSERT(!obj->IsLoaded());
}
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698