Make LiveEdit natives fuzzy

Review URL: http://codereview.chromium.org/1687022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4578 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
peter.rybin@gmail.com 2010-05-04 13:07:36 +00:00
parent 001f020d04
commit 5435396701
4 changed files with 26 additions and 22 deletions

View File

@ -545,6 +545,11 @@ class FunctionInfoWrapper : public JSArrayBasedStruct<FunctionInfoWrapper> {
// 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 @@ static bool IsJSFunctionCode(Code* code) {
}
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 @@ void LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
shared_info->set_construct_stub(
Builtins::builtin(Builtins::JSConstructStubGeneric));
// update breakpoints
return Heap::undefined_value();
}
@ -1024,8 +1034,13 @@ static Handle<Code> PatchPositionsInCode(Handle<Code> code,
}
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 @@ void LiveEdit::PatchFunctionPositions(
ReplaceCodeObject(info->code(), *patched_code);
}
}
return Heap::undefined_value();
}

View File

@ -83,14 +83,14 @@ class LiveEdit : AllStatic {
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

View File

@ -9762,9 +9762,7 @@ static Object* Runtime_LiveEditReplaceFunctionCode(Arguments args) {
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 @@ static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
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);
}

View File

@ -174,15 +174,6 @@ var knownProblems = {
// 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 = {