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

Side by Side Diff: src/objects.cc

Issue 10556004: Revert part of 11727 as it sometimes tanked V8 benchmark (raytrace) performance (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 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 | « src/objects.h ('k') | src/objects-inl.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 7545 matching lines...) Expand 10 before | Expand all | Expand 10 after
7556 return code->optimizable(); 7556 return code->optimizable();
7557 } 7557 }
7558 7558
7559 7559
7560 MaybeObject* JSObject::OptimizeAsPrototype() { 7560 MaybeObject* JSObject::OptimizeAsPrototype() {
7561 if (IsGlobalObject()) return this; 7561 if (IsGlobalObject()) return this;
7562 7562
7563 // Make sure prototypes are fast objects and their maps have the bit set 7563 // Make sure prototypes are fast objects and their maps have the bit set
7564 // so they remain fast. 7564 // so they remain fast.
7565 Map* proto_map = map(); 7565 Map* proto_map = map();
7566 if (!proto_map->used_for_prototype()) { 7566 if (!HasFastProperties()) {
7567 if (!HasFastProperties()) { 7567 MaybeObject* new_proto = TransformToFastProperties(0);
7568 MaybeObject* new_proto = TransformToFastProperties(0); 7568 if (new_proto->IsFailure()) return new_proto;
7569 if (new_proto->IsFailure()) return new_proto; 7569 ASSERT(new_proto == this);
7570 ASSERT(new_proto == this); 7570 proto_map = map();
7571 proto_map = map();
7572 if (!proto_map->is_shared()) {
7573 proto_map->set_used_for_prototype(true);
7574 }
7575 } else {
7576 Heap* heap = GetHeap();
7577 // We use the hole value as a singleton key in the prototype transition
7578 // map so that we don't multiply the number of maps unnecessarily.
7579 Map* new_map =
7580 proto_map->GetPrototypeTransition(heap->the_hole_value());
7581 if (new_map == NULL) {
7582 MaybeObject* maybe_new_map =
7583 proto_map->CopyDropTransitions(DescriptorArray::MAY_BE_SHARED);
7584 if (!maybe_new_map->To<Map>(&new_map)) return maybe_new_map;
7585 new_map->set_used_for_prototype(true);
7586 MaybeObject* ok =
7587 proto_map->PutPrototypeTransition(heap->the_hole_value(),
7588 new_map);
7589 if (ok->IsFailure()) return ok;
7590 }
7591 ASSERT(!proto_map->is_shared() && !new_map->is_shared());
7592 set_map(new_map);
7593 }
7594 } 7571 }
7595 return this; 7572 return this;
7596 } 7573 }
7597 7574
7598 7575
7599 MaybeObject* JSFunction::SetInstancePrototype(Object* value) { 7576 MaybeObject* JSFunction::SetInstancePrototype(Object* value) {
7600 ASSERT(value->IsJSReceiver()); 7577 ASSERT(value->IsJSReceiver());
7601 Heap* heap = GetHeap(); 7578 Heap* heap = GetHeap();
7602 7579
7603 // First some logic for the map of the prototype to make sure the 7580 // First some logic for the map of the prototype to make sure it is in fast
7604 // used_for_prototype flag is set. 7581 // mode.
7605 if (value->IsJSObject()) { 7582 if (value->IsJSObject()) {
7606 MaybeObject* ok = JSObject::cast(value)->OptimizeAsPrototype(); 7583 MaybeObject* ok = JSObject::cast(value)->OptimizeAsPrototype();
7607 if (ok->IsFailure()) return ok; 7584 if (ok->IsFailure()) return ok;
7608 } 7585 }
7609 7586
7610 // Now some logic for the maps of the objects that are created by using this 7587 // Now some logic for the maps of the objects that are created by using this
7611 // function as a constructor. 7588 // function as a constructor.
7612 if (has_initial_map()) { 7589 if (has_initial_map()) {
7613 // If the function has allocated the initial map 7590 // If the function has allocated the initial map
7614 // replace it with a copy containing the new prototype. 7591 // replace it with a copy containing the new prototype.
(...skipping 5658 matching lines...) Expand 10 before | Expand all | Expand 10 after
13273 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13250 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13274 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13251 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13275 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13252 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13276 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13253 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13277 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13254 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13278 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13255 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13279 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13256 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13280 } 13257 }
13281 13258
13282 } } // namespace v8::internal 13259 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698