Cleanup of HEAP and FACTORY macro usage in accessors.cc.

Patch by Peter Varga.

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


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7398 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vitalyr@chromium.org 2011-03-29 07:34:23 +00:00
parent 3187ef6ce8
commit 75c47bff99

View File

@ -100,14 +100,15 @@ Object* Accessors::FlattenNumber(Object* value) {
MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) { MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) {
Isolate* isolate = object->GetIsolate();
value = FlattenNumber(value); value = FlattenNumber(value);
// Need to call methods that may trigger GC. // Need to call methods that may trigger GC.
HandleScope scope; HandleScope scope(isolate);
// Protect raw pointers. // Protect raw pointers.
Handle<JSObject> object_handle(object); Handle<JSObject> object_handle(object, isolate);
Handle<Object> value_handle(value); Handle<Object> value_handle(value, isolate);
bool has_exception; bool has_exception;
Handle<Object> uint32_v = Execution::ToUint32(value_handle, &has_exception); Handle<Object> uint32_v = Execution::ToUint32(value_handle, &has_exception);
@ -126,13 +127,13 @@ MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) {
// This means one of the object's prototypes is a JSArray and // This means one of the object's prototypes is a JSArray and
// the object does not have a 'length' property. // the object does not have a 'length' property.
// Calling SetProperty causes an infinite loop. // Calling SetProperty causes an infinite loop.
return object->SetLocalPropertyIgnoreAttributes(HEAP->length_symbol(), return object->SetLocalPropertyIgnoreAttributes(
value, NONE); isolate->heap()->length_symbol(), value, NONE);
} }
} }
return Isolate::Current()->Throw( return isolate->Throw(
*FACTORY->NewRangeError("invalid_array_length", *isolate->factory()->NewRangeError("invalid_array_length",
HandleVector<Object>(NULL, 0))); HandleVector<Object>(NULL, 0)));
} }
@ -315,15 +316,18 @@ const AccessorDescriptor Accessors::ScriptCompilationType = {
MaybeObject* Accessors::ScriptGetLineEnds(Object* object, void*) { MaybeObject* Accessors::ScriptGetLineEnds(Object* object, void*) {
HandleScope scope; JSValue* wrapper = JSValue::cast(object);
Handle<Script> script(Script::cast(JSValue::cast(object)->value())); Isolate* isolate = wrapper->GetIsolate();
HandleScope scope(isolate);
Handle<Script> script(Script::cast(wrapper->value()), isolate);
InitScriptLineEnds(script); InitScriptLineEnds(script);
ASSERT(script->line_ends()->IsFixedArray()); ASSERT(script->line_ends()->IsFixedArray());
Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
// We do not want anyone to modify this array from JS. // We do not want anyone to modify this array from JS.
ASSERT(*line_ends == HEAP->empty_fixed_array() || ASSERT(*line_ends == isolate->heap()->empty_fixed_array() ||
line_ends->map() == HEAP->fixed_cow_array_map()); line_ends->map() == isolate->heap()->fixed_cow_array_map());
Handle<JSArray> js_array = FACTORY->NewJSArrayWithElements(line_ends); Handle<JSArray> js_array =
isolate->factory()->NewJSArrayWithElements(line_ends);
return *js_array; return *js_array;
} }
@ -444,9 +448,10 @@ const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = {
MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) { MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
Heap* heap = Isolate::Current()->heap();
bool found_it = false; bool found_it = false;
JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
if (!found_it) return HEAP->undefined_value(); if (!found_it) return heap->undefined_value();
while (!function->should_have_prototype()) { while (!function->should_have_prototype()) {
found_it = false; found_it = false;
function = FindInPrototypeChain<JSFunction>(object->GetPrototype(), function = FindInPrototypeChain<JSFunction>(object->GetPrototype(),
@ -457,7 +462,7 @@ MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
if (!function->has_prototype()) { if (!function->has_prototype()) {
Object* prototype; Object* prototype;
{ MaybeObject* maybe_prototype = HEAP->AllocateFunctionPrototype(function); { MaybeObject* maybe_prototype = heap->AllocateFunctionPrototype(function);
if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
} }
Object* result; Object* result;
@ -472,12 +477,13 @@ MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
MaybeObject* Accessors::FunctionSetPrototype(JSObject* object, MaybeObject* Accessors::FunctionSetPrototype(JSObject* object,
Object* value, Object* value,
void*) { void*) {
Heap* heap = object->GetHeap();
bool found_it = false; bool found_it = false;
JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
if (!found_it) return HEAP->undefined_value(); if (!found_it) return heap->undefined_value();
if (!function->should_have_prototype()) { if (!function->should_have_prototype()) {
// Since we hit this accessor, object will have no prototype property. // Since we hit this accessor, object will have no prototype property.
return object->SetLocalPropertyIgnoreAttributes(HEAP->prototype_symbol(), return object->SetLocalPropertyIgnoreAttributes(heap->prototype_symbol(),
value, value,
NONE); NONE);
} }