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

Side by Side Diff: src/objects.cc

Issue 27070002: Handlify JSObject::SetObserved (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cr changes Created 7 years, 2 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/runtime.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 5563 matching lines...) Expand 10 before | Expand all | Expand 10 after
5574 // Make sure we never go back to the fast case 5574 // Make sure we never go back to the fast case
5575 dictionary->set_requires_slow_elements(); 5575 dictionary->set_requires_slow_elements();
5576 // Freeze all elements in the dictionary 5576 // Freeze all elements in the dictionary
5577 FreezeDictionary(dictionary); 5577 FreezeDictionary(dictionary);
5578 } 5578 }
5579 5579
5580 return object; 5580 return object;
5581 } 5581 }
5582 5582
5583 5583
5584 MUST_USE_RESULT MaybeObject* JSObject::SetObserved(Isolate* isolate) { 5584 void JSObject::SetObserved(Handle<JSObject> object) {
5585 if (map()->is_observed()) 5585 Isolate* isolate = object->GetIsolate();
5586 return isolate->heap()->undefined_value();
5587 5586
5588 Heap* heap = isolate->heap(); 5587 if (object->map()->is_observed())
5588 return;
5589 5589
5590 if (!HasExternalArrayElements()) { 5590 if (!object->HasExternalArrayElements()) {
5591 // Go to dictionary mode, so that we don't skip map checks. 5591 // Go to dictionary mode, so that we don't skip map checks.
5592 MaybeObject* maybe = NormalizeElements(); 5592 NormalizeElements(object);
5593 if (maybe->IsFailure()) return maybe; 5593 ASSERT(!object->HasFastElements());
5594 ASSERT(!HasFastElements());
5595 } 5594 }
5596 5595
5597 LookupResult result(isolate); 5596 LookupResult result(isolate);
5598 map()->LookupTransition(this, heap->observed_symbol(), &result); 5597 object->map()->LookupTransition(*object,
5598 isolate->heap()->observed_symbol(),
5599 &result);
5599 5600
5600 Map* new_map; 5601 Handle<Map> new_map;
5601 if (result.IsTransition()) { 5602 if (result.IsTransition()) {
5602 new_map = result.GetTransitionTarget(); 5603 new_map = handle(result.GetTransitionTarget());
5603 ASSERT(new_map->is_observed()); 5604 ASSERT(new_map->is_observed());
5604 } else if (map()->CanHaveMoreTransitions()) { 5605 } else if (object->map()->CanHaveMoreTransitions()) {
5605 MaybeObject* maybe_new_map = map()->CopyForObserved(); 5606 new_map = Map::CopyForObserved(handle(object->map()));
5606 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
5607 } else { 5607 } else {
5608 MaybeObject* maybe_copy = map()->Copy(); 5608 new_map = Map::Copy(handle(object->map()));
5609 if (!maybe_copy->To(&new_map)) return maybe_copy;
5610 new_map->set_is_observed(true); 5609 new_map->set_is_observed(true);
5611 } 5610 }
5612 set_map(new_map); 5611 object->set_map(*new_map);
5613
5614 return heap->undefined_value();
5615 } 5612 }
5616 5613
5617 5614
5618 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) { 5615 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) {
5619 Isolate* isolate = object->GetIsolate(); 5616 Isolate* isolate = object->GetIsolate();
5620 CALL_HEAP_FUNCTION(isolate, 5617 CALL_HEAP_FUNCTION(isolate,
5621 isolate->heap()->CopyJSObject(*object), JSObject); 5618 isolate->heap()->CopyJSObject(*object), JSObject);
5622 } 5619 }
5623 5620
5624 5621
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
6832 if (insert_transition) { 6829 if (insert_transition) {
6833 MaybeObject* added_elements = set_elements_transition_map(new_map); 6830 MaybeObject* added_elements = set_elements_transition_map(new_map);
6834 if (added_elements->IsFailure()) return added_elements; 6831 if (added_elements->IsFailure()) return added_elements;
6835 new_map->SetBackPointer(this); 6832 new_map->SetBackPointer(this);
6836 } 6833 }
6837 6834
6838 return new_map; 6835 return new_map;
6839 } 6836 }
6840 6837
6841 6838
6839 Handle<Map> Map::CopyForObserved(Handle<Map> map) {
6840 CALL_HEAP_FUNCTION(map->GetIsolate(),
6841 map->CopyForObserved(),
6842 Map);
6843 }
6844
6845
6842 MaybeObject* Map::CopyForObserved() { 6846 MaybeObject* Map::CopyForObserved() {
6843 ASSERT(!is_observed()); 6847 ASSERT(!is_observed());
6844 6848
6845 // In case the map owned its own descriptors, share the descriptors and 6849 // In case the map owned its own descriptors, share the descriptors and
6846 // transfer ownership to the new map. 6850 // transfer ownership to the new map.
6847 Map* new_map; 6851 Map* new_map;
6848 MaybeObject* maybe_new_map; 6852 MaybeObject* maybe_new_map;
6849 if (owns_descriptors()) { 6853 if (owns_descriptors()) {
6850 maybe_new_map = CopyDropDescriptors(); 6854 maybe_new_map = CopyDropDescriptors();
6851 } else { 6855 } else {
(...skipping 9422 matching lines...) Expand 10 before | Expand all | Expand 10 after
16274 #define ERROR_MESSAGES_TEXTS(C, T) T, 16278 #define ERROR_MESSAGES_TEXTS(C, T) T,
16275 static const char* error_messages_[] = { 16279 static const char* error_messages_[] = {
16276 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16280 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16277 }; 16281 };
16278 #undef ERROR_MESSAGES_TEXTS 16282 #undef ERROR_MESSAGES_TEXTS
16279 return error_messages_[reason]; 16283 return error_messages_[reason];
16280 } 16284 }
16281 16285
16282 16286
16283 } } // namespace v8::internal 16287 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698