Revision: 4578
Author: [email protected]
Date: Tue May  4 06:07:36 2010
Log: Make LiveEdit natives fuzzy

Review URL: http://codereview.chromium.org/1687022
http://code.google.com/p/v8/source/detail?r=4578

Modified:
 /branches/bleeding_edge/src/liveedit.cc
 /branches/bleeding_edge/src/liveedit.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/test/mjsunit/fuzz-natives.js

=======================================
--- /branches/bleeding_edge/src/liveedit.cc     Wed Apr 28 04:38:43 2010
+++ /branches/bleeding_edge/src/liveedit.cc     Tue May  4 06:07:36 2010
@@ -545,6 +545,11 @@
 // wrapped into BlindReference for sanitizing reasons.
 class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> {
  public:
+  static bool IsInstance(Handle<JSArray> array) {
+    return array->length() == Smi::FromInt(kSize_) &&
+        array->GetElement(kSharedInfoOffset_)->IsJSValue();
+  }
+
   explicit SharedInfoWrapper(Handle<JSArray> array)
       : JSArrayBasedStruct<SharedInfoWrapper>(array) {
   }
@@ -834,10 +839,14 @@
 }


-void LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
-                                   Handle<JSArray> shared_info_array) {
+Object* LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
+                                      Handle<JSArray> shared_info_array) {
   HandleScope scope;

+  if (!SharedInfoWrapper::IsInstance(shared_info_array)) {
+    return Top::ThrowIllegalOperation();
+  }
+
   FunctionInfoWrapper compile_info_wrapper(new_compile_info_array);
   SharedInfoWrapper shared_info_wrapper(shared_info_array);

@@ -860,7 +869,8 @@

   shared_info->set_construct_stub(
       Builtins::builtin(Builtins::JSConstructStubGeneric));
-  // update breakpoints
+
+  return Heap::undefined_value();
 }


@@ -1024,8 +1034,13 @@
 }


-void LiveEdit::PatchFunctionPositions(
+Object* LiveEdit::PatchFunctionPositions(
Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) {
+
+  if (!SharedInfoWrapper::IsInstance(shared_info_array)) {
+    return Top::ThrowIllegalOperation();
+  }
+
   SharedInfoWrapper shared_info_wrapper(shared_info_array);
   Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo();

@@ -1053,6 +1068,8 @@
       ReplaceCodeObject(info->code(), *patched_code);
     }
   }
+
+  return Heap::undefined_value();
 }


=======================================
--- /branches/bleeding_edge/src/liveedit.h      Wed Apr 28 04:38:43 2010
+++ /branches/bleeding_edge/src/liveedit.h      Tue May  4 06:07:36 2010
@@ -83,14 +83,14 @@

   static void WrapSharedFunctionInfos(Handle<JSArray> array);

-  static void ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
-                                  Handle<JSArray> shared_info_array);
+ static Object* ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
+                                     Handle<JSArray> shared_info_array);

   // Updates script field in FunctionSharedInfo.
   static void SetFunctionScript(Handle<JSValue> function_wrapper,
                                 Handle<Object> script_handle);

-  static void PatchFunctionPositions(
+  static Object* PatchFunctionPositions(
Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array);

   // For a script updates its source field. If old_script_name is provided
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Fri Apr 30 03:27:25 2010
+++ /branches/bleeding_edge/src/runtime.cc      Tue May  4 06:07:36 2010
@@ -9762,9 +9762,7 @@
   CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0);
   CONVERT_ARG_CHECKED(JSArray, shared_info, 1);

-  LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
-
-  return Heap::undefined_value();
+  return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
 }

 // Connects SharedFunctionInfo to another script.
@@ -9819,9 +9817,7 @@
   CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
   CONVERT_ARG_CHECKED(JSArray, position_change_array, 1);

-  LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
-
-  return Heap::undefined_value();
+ return LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
 }


=======================================
--- /branches/bleeding_edge/test/mjsunit/fuzz-natives.js Thu Apr 29 08:14:39 2010 +++ /branches/bleeding_edge/test/mjsunit/fuzz-natives.js Tue May 4 06:07:36 2010
@@ -174,15 +174,6 @@
   // This function performs some checks compile time (it requires its first
   // argument to be a compile time smi).
   "_GetFromCache": true,
-
-  // LiveEdit feature is under development currently and has fragile input.
-  "LiveEditFindSharedFunctionInfosForScript": true,
-  "LiveEditGatherCompileInfo": true,
-  "LiveEditReplaceScript": true,
-  "LiveEditReplaceFunctionCode": true,
-  "LiveEditRelinkFunctionToScript": true,
-  "LiveEditPatchFunctionPositions": true,
-  "LiveEditCheckStackActivations": true
 };

 var currentlyUncallable = {

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to