Commit 9045e2e6 authored by vegorov@chromium.org's avatar vegorov@chromium.org

Fix more GC unsafe places

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5530 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 25f31f13
...@@ -2658,8 +2658,9 @@ void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { ...@@ -2658,8 +2658,9 @@ void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
return; return;
} }
i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(length, data); i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(length, data);
self->set_map( i::Handle<i::Map> slow_map =
*i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()))); i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()));
self->set_map(*slow_map);
self->set_elements(*pixels); self->set_elements(*pixels);
} }
...@@ -2713,8 +2714,9 @@ void v8::Object::SetIndexedPropertiesToExternalArrayData( ...@@ -2713,8 +2714,9 @@ void v8::Object::SetIndexedPropertiesToExternalArrayData(
} }
i::Handle<i::ExternalArray> array = i::Handle<i::ExternalArray> array =
i::Factory::NewExternalArray(length, array_type, data); i::Factory::NewExternalArray(length, array_type, data);
self->set_map( i::Handle<i::Map> slow_map =
*i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()))); i::Factory::GetSlowElementsMap(i::Handle<i::Map>(self->map()));
self->set_map(*slow_map);
self->set_elements(*array); self->set_elements(*array);
} }
......
...@@ -1064,8 +1064,11 @@ bool Genesis::InstallNatives() { ...@@ -1064,8 +1064,11 @@ bool Genesis::InstallNatives() {
// global object. // global object.
static const PropertyAttributes attributes = static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
SetProperty(builtins, Factory::LookupAsciiSymbol("global"), Handle<String> global_symbol = Factory::LookupAsciiSymbol("global");
Handle<Object>(global_context()->global()), attributes); SetProperty(builtins,
global_symbol,
Handle<Object>(global_context()->global()),
attributes);
// Setup the reference from the global object to the builtins object. // Setup the reference from the global object to the builtins object.
JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins); JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins);
......
...@@ -1034,10 +1034,12 @@ bool Debug::CheckBreakPoint(Handle<Object> break_point_object) { ...@@ -1034,10 +1034,12 @@ bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
if (!break_point_object->IsJSObject()) return true; if (!break_point_object->IsJSObject()) return true;
// Get the function CheckBreakPoint (defined in debug.js). // Get the function CheckBreakPoint (defined in debug.js).
Handle<String> is_break_point_triggered_symbol =
Factory::LookupAsciiSymbol("IsBreakPointTriggered");
Handle<JSFunction> check_break_point = Handle<JSFunction> check_break_point =
Handle<JSFunction>(JSFunction::cast( Handle<JSFunction>(JSFunction::cast(
debug_context()->global()->GetProperty( debug_context()->global()->GetProperty(
*Factory::LookupAsciiSymbol("IsBreakPointTriggered")))); *is_break_point_triggered_symbol)));
// Get the break id as an object. // Get the break id as an object.
Handle<Object> break_id = Factory::NewNumberFromInt(Debug::break_id()); Handle<Object> break_id = Factory::NewNumberFromInt(Debug::break_id());
...@@ -2176,9 +2178,11 @@ void Debugger::OnAfterCompile(Handle<Script> script, ...@@ -2176,9 +2178,11 @@ void Debugger::OnAfterCompile(Handle<Script> script,
// script. Make sure that these break points are set. // script. Make sure that these break points are set.
// Get the function UpdateScriptBreakPoints (defined in debug-debugger.js). // Get the function UpdateScriptBreakPoints (defined in debug-debugger.js).
Handle<String> update_script_break_points_symbol =
Factory::LookupAsciiSymbol("UpdateScriptBreakPoints");
Handle<Object> update_script_break_points = Handle<Object> update_script_break_points =
Handle<Object>(Debug::debug_context()->global()->GetProperty( Handle<Object>(Debug::debug_context()->global()->GetProperty(
*Factory::LookupAsciiSymbol("UpdateScriptBreakPoints"))); *update_script_break_points_symbol));
if (!update_script_break_points->IsJSFunction()) { if (!update_script_break_points->IsJSFunction()) {
return; return;
} }
......
...@@ -638,8 +638,8 @@ static Object* Runtime_GetOwnProperty(Arguments args) { ...@@ -638,8 +638,8 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
Handle<FixedArray> elms = Factory::NewFixedArray(DESCRIPTOR_SIZE); Handle<FixedArray> elms = Factory::NewFixedArray(DESCRIPTOR_SIZE);
Handle<JSArray> desc = Factory::NewJSArrayWithElements(elms); Handle<JSArray> desc = Factory::NewJSArrayWithElements(elms);
LookupResult result; LookupResult result;
CONVERT_CHECKED(JSObject, obj, args[0]); CONVERT_ARG_CHECKED(JSObject, obj, 0);
CONVERT_CHECKED(String, name, args[1]); CONVERT_ARG_CHECKED(String, name, 1);
// This could be an element. // This could be an element.
uint32_t index; uint32_t index;
...@@ -653,10 +653,12 @@ static Object* Runtime_GetOwnProperty(Arguments args) { ...@@ -653,10 +653,12 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
// 15.5.5.2. Note that this might be a string object with elements // 15.5.5.2. Note that this might be a string object with elements
// other than the actual string value. This is covered by the // other than the actual string value. This is covered by the
// subsequent cases. // subsequent cases.
JSValue* js_value = JSValue::cast(obj); Handle<JSValue> js_value = Handle<JSValue>::cast(obj);
String* str = String::cast(js_value->value()); Handle<String> str(String::cast(js_value->value()));
Handle<String> substr = SubString(str, index, index+1, NOT_TENURED);
elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
elms->set(VALUE_INDEX, str->SubString(index, index+1)); elms->set(VALUE_INDEX, *substr);
elms->set(WRITABLE_INDEX, Heap::false_value()); elms->set(WRITABLE_INDEX, Heap::false_value());
elms->set(ENUMERABLE_INDEX, Heap::false_value()); elms->set(ENUMERABLE_INDEX, Heap::false_value());
elms->set(CONFIGURABLE_INDEX, Heap::false_value()); elms->set(CONFIGURABLE_INDEX, Heap::false_value());
...@@ -664,13 +666,15 @@ static Object* Runtime_GetOwnProperty(Arguments args) { ...@@ -664,13 +666,15 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
} }
case JSObject::INTERCEPTED_ELEMENT: case JSObject::INTERCEPTED_ELEMENT:
case JSObject::FAST_ELEMENT: case JSObject::FAST_ELEMENT: {
elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
elms->set(VALUE_INDEX, obj->GetElement(index)); Handle<Object> element = GetElement(Handle<Object>(obj), index);
elms->set(VALUE_INDEX, *element);
elms->set(WRITABLE_INDEX, Heap::true_value()); elms->set(WRITABLE_INDEX, Heap::true_value());
elms->set(ENUMERABLE_INDEX, Heap::true_value()); elms->set(ENUMERABLE_INDEX, Heap::true_value());
elms->set(CONFIGURABLE_INDEX, Heap::true_value()); elms->set(CONFIGURABLE_INDEX, Heap::true_value());
return *desc; return *desc;
}
case JSObject::DICTIONARY_ELEMENT: { case JSObject::DICTIONARY_ELEMENT: {
NumberDictionary* dictionary = obj->element_dictionary(); NumberDictionary* dictionary = obj->element_dictionary();
...@@ -705,7 +709,7 @@ static Object* Runtime_GetOwnProperty(Arguments args) { ...@@ -705,7 +709,7 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
} }
// Use recursive implementation to also traverse hidden prototypes // Use recursive implementation to also traverse hidden prototypes
GetOwnPropertyImplementation(obj, name, &result); GetOwnPropertyImplementation(*obj, *name, &result);
if (!result.IsProperty()) { if (!result.IsProperty()) {
return Heap::undefined_value(); return Heap::undefined_value();
...@@ -716,7 +720,8 @@ static Object* Runtime_GetOwnProperty(Arguments args) { ...@@ -716,7 +720,8 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
// Property that is internally implemented as a callback or // Property that is internally implemented as a callback or
// an API defined callback. // an API defined callback.
Object* value = obj->GetPropertyWithCallback( Object* value = obj->GetPropertyWithCallback(
obj, structure, name, result.holder()); *obj, structure, *name, result.holder());
if (value->IsFailure()) return value;
elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
elms->set(VALUE_INDEX, value); elms->set(VALUE_INDEX, value);
elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly())); elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly()));
...@@ -7537,14 +7542,18 @@ static Object* Runtime_ArrayConcat(Arguments args) { ...@@ -7537,14 +7542,18 @@ static Object* Runtime_ArrayConcat(Arguments args) {
// The backing storage array must have non-existing elements to // The backing storage array must have non-existing elements to
// preserve holes across concat operations. // preserve holes across concat operations.
storage = Factory::NewFixedArrayWithHoles(result_length); storage = Factory::NewFixedArrayWithHoles(result_length);
result->set_map(*Factory::GetFastElementsMap(Handle<Map>(result->map()))); Handle<Map> fast_map =
Factory::GetFastElementsMap(Handle<Map>(result->map()));
result->set_map(*fast_map);
} else { } else {
// TODO(126): move 25% pre-allocation logic into Dictionary::Allocate // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate
uint32_t at_least_space_for = estimate_nof_elements + uint32_t at_least_space_for = estimate_nof_elements +
(estimate_nof_elements >> 2); (estimate_nof_elements >> 2);
storage = Handle<FixedArray>::cast( storage = Handle<FixedArray>::cast(
Factory::NewNumberDictionary(at_least_space_for)); Factory::NewNumberDictionary(at_least_space_for));
result->set_map(*Factory::GetSlowElementsMap(Handle<Map>(result->map()))); Handle<Map> slow_map =
Factory::GetSlowElementsMap(Handle<Map>(result->map()));
result->set_map(*slow_map);
} }
Handle<Object> len = Factory::NewNumber(static_cast<double>(result_length)); Handle<Object> len = Factory::NewNumber(static_cast<double>(result_length));
...@@ -9079,10 +9088,10 @@ static Handle<Context> CopyWithContextChain(Handle<Context> context_chain, ...@@ -9079,10 +9088,10 @@ static Handle<Context> CopyWithContextChain(Handle<Context> context_chain,
// Recursively copy the with contexts. // Recursively copy the with contexts.
Handle<Context> previous(context_chain->previous()); Handle<Context> previous(context_chain->previous());
Handle<JSObject> extension(JSObject::cast(context_chain->extension())); Handle<JSObject> extension(JSObject::cast(context_chain->extension()));
return Factory::NewWithContext( Handle<Context> context = CopyWithContextChain(function_context, previous);
CopyWithContextChain(function_context, previous), return Factory::NewWithContext(context,
extension, extension,
context_chain->IsCatchContext()); context_chain->IsCatchContext());
} }
......
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