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

Side by Side Diff: src/accessors.cc

Issue 6548008: Fix second half of issue 1151, the first change (r6765) only fixed FunctionGe... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 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 | test/mjsunit/regress/regress-1151.js » ('j') | 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 // 440 //
441 // Accessors::FunctionPrototype 441 // Accessors::FunctionPrototype
442 // 442 //
443 443
444 444
445 MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) { 445 MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
446 bool found_it = false; 446 bool found_it = false;
447 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); 447 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
448 if (!found_it) return Heap::undefined_value(); 448 if (!found_it) return Heap::undefined_value();
449 while (!function->should_have_prototype()) {
450 found_it = false;
451 function = FindInPrototypeChain<JSFunction>(object->GetPrototype(),
452 &found_it);
453 // There has to be one because we hit the getter.
454 ASSERT(found_it);
455 }
456
449 if (!function->has_prototype()) { 457 if (!function->has_prototype()) {
450 if (!function->should_have_prototype()) return Heap::undefined_value();
451 Object* prototype; 458 Object* prototype;
452 { MaybeObject* maybe_prototype = Heap::AllocateFunctionPrototype(function); 459 { MaybeObject* maybe_prototype = Heap::AllocateFunctionPrototype(function);
453 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; 460 if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
454 } 461 }
455 Object* result; 462 Object* result;
456 { MaybeObject* maybe_result = function->SetPrototype(prototype); 463 { MaybeObject* maybe_result = function->SetPrototype(prototype);
457 if (!maybe_result->ToObject(&result)) return maybe_result; 464 if (!maybe_result->ToObject(&result)) return maybe_result;
458 } 465 }
459 } 466 }
460 return function->prototype(); 467 return function->prototype();
461 } 468 }
462 469
463 470
464 MaybeObject* Accessors::FunctionSetPrototype(JSObject* object, 471 MaybeObject* Accessors::FunctionSetPrototype(JSObject* object,
465 Object* value, 472 Object* value,
466 void*) { 473 void*) {
467 bool found_it = false; 474 bool found_it = false;
468 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it); 475 JSFunction* function = FindInPrototypeChain<JSFunction>(object, &found_it);
469 if (!found_it) return Heap::undefined_value(); 476 if (!found_it) return Heap::undefined_value();
477 if (!function->should_have_prototype()) {
478 // Since we hit this accessor, object will have no prototype property.
479 return object->SetLocalPropertyIgnoreAttributes(Heap::prototype_symbol(),
480 value,
481 NONE);
482 }
483
470 if (function->has_initial_map()) { 484 if (function->has_initial_map()) {
471 // If the function has allocated the initial map 485 // If the function has allocated the initial map
472 // replace it with a copy containing the new prototype. 486 // replace it with a copy containing the new prototype.
473 Object* new_map; 487 Object* new_map;
474 { MaybeObject* maybe_new_map = 488 { MaybeObject* maybe_new_map =
475 function->initial_map()->CopyDropTransitions(); 489 function->initial_map()->CopyDropTransitions();
476 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; 490 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
477 } 491 }
478 function->set_initial_map(Map::cast(new_map)); 492 function->set_initial_map(Map::cast(new_map));
479 } 493 }
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } 898 }
885 899
886 900
887 const AccessorDescriptor Accessors::ObjectPrototype = { 901 const AccessorDescriptor Accessors::ObjectPrototype = {
888 ObjectGetPrototype, 902 ObjectGetPrototype,
889 ObjectSetPrototype, 903 ObjectSetPrototype,
890 0 904 0
891 }; 905 };
892 906
893 } } // namespace v8::internal 907 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1151.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698