Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: src/accessors.cc

Issue 6756003: Cleanup of HEAP and FACTORY macro usage in accessors.cc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 bool has_exception; 112 bool has_exception;
113 Handle<Object> uint32_v = Execution::ToUint32(value_handle, &has_exception); 113 Handle<Object> uint32_v = Execution::ToUint32(value_handle, &has_exception);
114 if (has_exception) return Failure::Exception(); 114 if (has_exception) return Failure::Exception();
115 Handle<Object> number_v = Execution::ToNumber(value_handle, &has_exception); 115 Handle<Object> number_v = Execution::ToNumber(value_handle, &has_exception);
116 if (has_exception) return Failure::Exception(); 116 if (has_exception) return Failure::Exception();
117 117
118 // Restore raw pointers, 118 // Restore raw pointers,
119 object = *object_handle; 119 object = *object_handle;
120 value = *value_handle; 120 value = *value_handle;
121 121
122 Isolate* isolate = Isolate::Current();
Mads Ager (chromium) 2011/03/28 12:59:52 Please get the isolate from the object parameter i
123
122 if (uint32_v->Number() == number_v->Number()) { 124 if (uint32_v->Number() == number_v->Number()) {
123 if (object->IsJSArray()) { 125 if (object->IsJSArray()) {
124 return JSArray::cast(object)->SetElementsLength(*uint32_v); 126 return JSArray::cast(object)->SetElementsLength(*uint32_v);
125 } else { 127 } else {
126 // This means one of the object's prototypes is a JSArray and 128 // This means one of the object's prototypes is a JSArray and
127 // the object does not have a 'length' property. 129 // the object does not have a 'length' property.
128 // Calling SetProperty causes an infinite loop. 130 // Calling SetProperty causes an infinite loop.
129 return object->SetLocalPropertyIgnoreAttributes(HEAP->length_symbol(), 131 return object->SetLocalPropertyIgnoreAttributes(
130 value, NONE); 132 isolate->heap()->length_symbol(), value, NONE);
131 } 133 }
132 } 134 }
133 return Isolate::Current()->Throw( 135 return isolate->Throw(
134 *FACTORY->NewRangeError("invalid_array_length", 136 *isolate->factory()->NewRangeError("invalid_array_length",
135 HandleVector<Object>(NULL, 0))); 137 HandleVector<Object>(NULL, 0)));
136 } 138 }
137 139
138 140
139 const AccessorDescriptor Accessors::ArrayLength = { 141 const AccessorDescriptor Accessors::ArrayLength = {
140 ArrayGetLength, 142 ArrayGetLength,
141 ArraySetLength, 143 ArraySetLength,
142 0 144 0
143 }; 145 };
144 146
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 0 310 0
309 }; 311 };
310 312
311 313
312 // 314 //
313 // Accessors::ScriptGetLineEnds 315 // Accessors::ScriptGetLineEnds
314 // 316 //
315 317
316 318
317 MaybeObject* Accessors::ScriptGetLineEnds(Object* object, void*) { 319 MaybeObject* Accessors::ScriptGetLineEnds(Object* object, void*) {
320 Isolate* isolate = Isolate::Current();
Mads Ager (chromium) 2011/03/28 12:59:52 Please extract the isolate from the object. The ob
318 HandleScope scope; 321 HandleScope scope;
319 Handle<Script> script(Script::cast(JSValue::cast(object)->value())); 322 Handle<Script> script(Script::cast(JSValue::cast(object)->value()));
320 InitScriptLineEnds(script); 323 InitScriptLineEnds(script);
321 ASSERT(script->line_ends()->IsFixedArray()); 324 ASSERT(script->line_ends()->IsFixedArray());
322 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 325 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
323 // We do not want anyone to modify this array from JS. 326 // We do not want anyone to modify this array from JS.
324 ASSERT(*line_ends == HEAP->empty_fixed_array() || 327 ASSERT(*line_ends == isolate->heap()->empty_fixed_array() ||
325 line_ends->map() == HEAP->fixed_cow_array_map()); 328 line_ends->map() == isolate->heap()->fixed_cow_array_map());
326 Handle<JSArray> js_array = FACTORY->NewJSArrayWithElements(line_ends); 329 Handle<JSArray> js_array =
330 isolate->factory()->NewJSArrayWithElements(line_ends);
327 return *js_array; 331 return *js_array;
328 } 332 }
329 333
330 334
331 const AccessorDescriptor Accessors::ScriptLineEnds = { 335 const AccessorDescriptor Accessors::ScriptLineEnds = {
332 ScriptGetLineEnds, 336 ScriptGetLineEnds,
333 IllegalSetter, 337 IllegalSetter,
334 0 338 0
335 }; 339 };
336 340
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 0 441 0
438 }; 442 };
439 443
440 444
441 // 445 //
442 // Accessors::FunctionPrototype 446 // Accessors::FunctionPrototype
443 // 447 //
444 448
445 449
446 MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) { 450 MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
451 Heap* heap = HEAP;
447 bool found_it = false; 452 bool found_it = false;
448 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); 453 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
449 if (!found_it) return HEAP->undefined_value(); 454 if (!found_it) return heap->undefined_value();
450 while (!function->should_have_prototype()) { 455 while (!function->should_have_prototype()) {
451 found_it = false; 456 found_it = false;
452 function = FindInPrototypeChain<JSFunction>(object->GetPrototype(), 457 function = FindInPrototypeChain<JSFunction>(object->GetPrototype(),
453 &found_it); 458 &found_it);
454 // There has to be one because we hit the getter. 459 // There has to be one because we hit the getter.
455 ASSERT(found_it); 460 ASSERT(found_it);
456 } 461 }
457 462
458 if (!function->has_prototype()) { 463 if (!function->has_prototype()) {
459 Object* prototype; 464 Object* prototype;
460 { MaybeObject* maybe_prototype = HEAP->AllocateFunctionPrototype(function); 465 { MaybeObject* maybe_prototype = heap->AllocateFunctionPrototype(function);
461 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; 466 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
462 } 467 }
463 Object* result; 468 Object* result;
464 { MaybeObject* maybe_result = function->SetPrototype(prototype); 469 { MaybeObject* maybe_result = function->SetPrototype(prototype);
465 if (!maybe_result->ToObject(&result)) return maybe_result; 470 if (!maybe_result->ToObject(&result)) return maybe_result;
466 } 471 }
467 } 472 }
468 return function->prototype(); 473 return function->prototype();
469 } 474 }
470 475
471 476
472 MaybeObject* Accessors::FunctionSetPrototype(JSObject* object, 477 MaybeObject* Accessors::FunctionSetPrototype(JSObject* object,
473 Object* value, 478 Object* value,
474 void*) { 479 void*) {
480 Heap* heap = HEAP;
475 bool found_it = false; 481 bool found_it = false;
476 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); 482 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
477 if (!found_it) return HEAP->undefined_value(); 483 if (!found_it) return heap->undefined_value();
478 if (!function->should_have_prototype()) { 484 if (!function->should_have_prototype()) {
479 // Since we hit this accessor, object will have no prototype property. 485 // Since we hit this accessor, object will have no prototype property.
480 return object->SetLocalPropertyIgnoreAttributes(HEAP->prototype_symbol(), 486 return object->SetLocalPropertyIgnoreAttributes(heap->prototype_symbol(),
481 value, 487 value,
482 NONE); 488 NONE);
483 } 489 }
484 490
485 if (function->has_initial_map()) { 491 if (function->has_initial_map()) {
486 // If the function has allocated the initial map 492 // If the function has allocated the initial map
487 // replace it with a copy containing the new prototype. 493 // replace it with a copy containing the new prototype.
488 Object* new_map; 494 Object* new_map;
489 { MaybeObject* maybe_new_map = 495 { MaybeObject* maybe_new_map =
490 function->initial_map()->CopyDropTransitions(); 496 function->initial_map()->CopyDropTransitions();
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 } 921 }
916 922
917 923
918 const AccessorDescriptor Accessors::ObjectPrototype = { 924 const AccessorDescriptor Accessors::ObjectPrototype = {
919 ObjectGetPrototype, 925 ObjectGetPrototype,
920 ObjectSetPrototype, 926 ObjectSetPrototype,
921 0 927 0
922 }; 928 };
923 929
924 } } // namespace v8::internal 930 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698