Commit d919609b authored by vegorov@chromium.org's avatar vegorov@chromium.org

Fix a number of GC-unsafe evaluation order dependent places.

Also change places which are triggering false positive alert in our static analysis tool.
 
Review URL: http://codereview.chromium.org/6731054

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7432 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1e856300
......@@ -4246,7 +4246,9 @@ Local<v8::Array> v8::Array::New(int length) {
ENTER_V8(isolate);
int real_length = length > 0 ? length : 0;
i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length);
obj->set_length(*isolate->factory()->NewNumberFromInt(real_length));
i::Handle<i::Object> length_obj =
isolate->factory()->NewNumberFromInt(real_length);
obj->set_length(*length_obj);
return Utils::ToLocal(obj);
}
......
......@@ -400,19 +400,22 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() {
// Please note that the prototype property for function instances must be
// writable.
global_context()->set_function_instance_map(
*CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE));
Handle<Map> function_instance_map =
CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
global_context()->set_function_instance_map(*function_instance_map);
// Functions with this map will not have a 'prototype' property, and
// can not be used as constructors.
Handle<Map> function_without_prototype_map =
CreateFunctionMap(DONT_ADD_PROTOTYPE);
global_context()->set_function_without_prototype_map(
*CreateFunctionMap(DONT_ADD_PROTOTYPE));
*function_without_prototype_map);
// Allocate the function map. This map is temporary, used only for processing
// of builtins.
// Later the map is replaced with writable prototype map, allocated below.
global_context()->set_function_map(
*CreateFunctionMap(ADD_READONLY_PROTOTYPE));
Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE);
global_context()->set_function_map(*function_map);
// The final map for functions. Writeable prototype.
// This map is installed in MakeFunctionInstancePrototypeWritable.
......@@ -474,8 +477,6 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() {
function_instance_map_writable_prototype_->set_prototype(*empty_function);
// Allocate the function map first and then patch the prototype later
Handle<Map> function_without_prototype_map(
global_context()->function_without_prototype_map());
Handle<Map> empty_fm = factory->CopyMapDropDescriptors(
function_without_prototype_map);
empty_fm->set_instance_descriptors(
......@@ -578,21 +579,27 @@ void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
// Allocate map for the strict mode function instances.
Handle<Map> strict_mode_function_instance_map =
CreateStrictModeFunctionMap(
ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
global_context()->set_strict_mode_function_instance_map(
*CreateStrictModeFunctionMap(
ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller));
*strict_mode_function_instance_map);
// Allocate map for the prototype-less strict mode instances.
Handle<Map> strict_mode_function_without_prototype_map =
CreateStrictModeFunctionMap(
DONT_ADD_PROTOTYPE, empty, arguments, caller);
global_context()->set_strict_mode_function_without_prototype_map(
*CreateStrictModeFunctionMap(
DONT_ADD_PROTOTYPE, empty, arguments, caller));
*strict_mode_function_without_prototype_map);
// Allocate map for the strict mode functions. This map is temporary, used
// only for processing of builtins.
// Later the map is replaced with writable prototype map, allocated below.
Handle<Map> strict_mode_function_map =
CreateStrictModeFunctionMap(
ADD_READONLY_PROTOTYPE, empty, arguments, caller);
global_context()->set_strict_mode_function_map(
*CreateStrictModeFunctionMap(
ADD_READONLY_PROTOTYPE, empty, arguments, caller));
*strict_mode_function_map);
// The final map for the strict mode functions. Writeable prototype.
// This map is installed in MakeFunctionInstancePrototypeWritable.
......@@ -1239,10 +1246,11 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
}
#define INSTALL_NATIVE(Type, name, var) \
Handle<String> var##_name = factory->LookupAsciiSymbol(name); \
global_context()->set_##var(Type::cast( \
global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name)));
#define INSTALL_NATIVE(Type, name, var) \
Handle<String> var##_name = factory->LookupAsciiSymbol(name); \
Object* var##_native = \
global_context()->builtins()->GetPropertyNoExceptionThrown(*var##_name); \
global_context()->set_##var(Type::cast(var##_native));
void Genesis::InstallNativeFunctions() {
......
......@@ -1013,8 +1013,8 @@ MaybeObject* LiveEdit::ReplaceFunctionCode(
Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
if (IsJSFunctionCode(shared_info->code())) {
ReplaceCodeObject(shared_info->code(),
*(compile_info_wrapper.GetFunctionCode()));
Handle<Code> code = compile_info_wrapper.GetFunctionCode();
ReplaceCodeObject(shared_info->code(), *code);
Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo();
if (code_scope_info->IsFixedArray()) {
shared_info->set_scope_info(SerializedScopeInfo::cast(*code_scope_info));
......@@ -1028,8 +1028,10 @@ MaybeObject* LiveEdit::ReplaceFunctionCode(
debug_info->set_original_code(*new_original_code);
}
shared_info->set_start_position(compile_info_wrapper.GetStartPosition());
shared_info->set_end_position(compile_info_wrapper.GetEndPosition());
int start_position = compile_info_wrapper.GetStartPosition();
int end_position = compile_info_wrapper.GetEndPosition();
shared_info->set_start_position(start_position);
shared_info->set_end_position(end_position);
shared_info->set_construct_stub(
Isolate::Current()->builtins()->builtin(
......@@ -1233,13 +1235,14 @@ MaybeObject* LiveEdit::PatchFunctionPositions(
int old_function_start = info->start_position();
int new_function_start = TranslatePosition(old_function_start,
position_change_array);
info->set_start_position(new_function_start);
info->set_end_position(TranslatePosition(info->end_position(),
position_change_array));
int new_function_end = TranslatePosition(info->end_position(),
position_change_array);
int new_function_token_pos =
TranslatePosition(info->function_token_position(), position_change_array);
info->set_function_token_position(
TranslatePosition(info->function_token_position(),
position_change_array));
info->set_start_position(new_function_start);
info->set_end_position(new_function_end);
info->set_function_token_position(new_function_token_pos);
if (IsJSFunctionCode(info->code())) {
// Patch relocation info section of the code.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment