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

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: cleanup 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') | src/runtime.cc » ('J')
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 5553 matching lines...) Expand 10 before | Expand all | Expand 10 after
5564 // Make sure we never go back to the fast case 5564 // Make sure we never go back to the fast case
5565 dictionary->set_requires_slow_elements(); 5565 dictionary->set_requires_slow_elements();
5566 // Freeze all elements in the dictionary 5566 // Freeze all elements in the dictionary
5567 FreezeDictionary(dictionary); 5567 FreezeDictionary(dictionary);
5568 } 5568 }
5569 5569
5570 return object; 5570 return object;
5571 } 5571 }
5572 5572
5573 5573
5574 MUST_USE_RESULT MaybeObject* JSObject::SetObserved(Isolate* isolate) { 5574 void JSObject::SetObserved(Handle<JSObject> object) {
5575 if (map()->is_observed()) 5575 Isolate* isolate = object->GetIsolate();
5576 return isolate->heap()->undefined_value();
5577 5576
5578 Heap* heap = isolate->heap(); 5577 if (object->map()->is_observed())
5578 return;
5579 5579
5580 if (!HasExternalArrayElements()) { 5580 if (!object->HasExternalArrayElements()) {
5581 // Go to dictionary mode, so that we don't skip map checks. 5581 // Go to dictionary mode, so that we don't skip map checks.
5582 MaybeObject* maybe = NormalizeElements(); 5582 NormalizeElements(object);
5583 if (maybe->IsFailure()) return maybe; 5583 ASSERT(!object->HasFastElements());
5584 ASSERT(!HasFastElements());
5585 } 5584 }
5586 5585
5587 LookupResult result(isolate); 5586 LookupResult result(isolate);
5588 map()->LookupTransition(this, heap->observed_symbol(), &result); 5587 object->map()->LookupTransition(*object,
5588 isolate->heap()->observed_symbol(),
5589 &result);
5589 5590
5590 Map* new_map; 5591 Handle<Map> new_map;
5591 if (result.IsTransition()) { 5592 if (result.IsTransition()) {
5592 new_map = result.GetTransitionTarget(); 5593 new_map = handle(result.GetTransitionTarget());
5593 ASSERT(new_map->is_observed()); 5594 ASSERT(new_map->is_observed());
5594 } else if (map()->CanHaveMoreTransitions()) { 5595 } else if (object->map()->CanHaveMoreTransitions()) {
5595 MaybeObject* maybe_new_map = map()->CopyForObserved(); 5596 new_map = Map::CopyForObserved(handle(object->map()));
5596 if (!maybe_new_map->To(&new_map)) return maybe_new_map;
5597 } else { 5597 } else {
5598 MaybeObject* maybe_copy = map()->Copy(); 5598 new_map = Map::Copy(handle(object->map()));
5599 if (!maybe_copy->To(&new_map)) return maybe_copy;
5600 new_map->set_is_observed(true); 5599 new_map->set_is_observed(true);
5601 } 5600 }
5602 set_map(new_map); 5601 object->set_map(*new_map);
5603
5604 return heap->undefined_value();
5605 } 5602 }
5606 5603
5607 5604
5608 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) { 5605 Handle<JSObject> JSObject::Copy(Handle<JSObject> object) {
5609 Isolate* isolate = object->GetIsolate(); 5606 Isolate* isolate = object->GetIsolate();
5610 CALL_HEAP_FUNCTION(isolate, 5607 CALL_HEAP_FUNCTION(isolate,
5611 isolate->heap()->CopyJSObject(*object), JSObject); 5608 isolate->heap()->CopyJSObject(*object), JSObject);
5612 } 5609 }
5613 5610
5614 5611
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
6822 if (insert_transition) { 6819 if (insert_transition) {
6823 MaybeObject* added_elements = set_elements_transition_map(new_map); 6820 MaybeObject* added_elements = set_elements_transition_map(new_map);
6824 if (added_elements->IsFailure()) return added_elements; 6821 if (added_elements->IsFailure()) return added_elements;
6825 new_map->SetBackPointer(this); 6822 new_map->SetBackPointer(this);
6826 } 6823 }
6827 6824
6828 return new_map; 6825 return new_map;
6829 } 6826 }
6830 6827
6831 6828
6829 Handle<Map> Map::CopyForObserved(Handle<Map> map) {
6830 CALL_HEAP_FUNCTION(map->GetIsolate(),
6831 map->CopyForObserved(),
6832 Map);
6833 }
6834
6835
6832 MaybeObject* Map::CopyForObserved() { 6836 MaybeObject* Map::CopyForObserved() {
6833 ASSERT(!is_observed()); 6837 ASSERT(!is_observed());
6834 6838
6835 // In case the map owned its own descriptors, share the descriptors and 6839 // In case the map owned its own descriptors, share the descriptors and
6836 // transfer ownership to the new map. 6840 // transfer ownership to the new map.
6837 Map* new_map; 6841 Map* new_map;
6838 MaybeObject* maybe_new_map; 6842 MaybeObject* maybe_new_map;
6839 if (owns_descriptors()) { 6843 if (owns_descriptors()) {
6840 maybe_new_map = CopyDropDescriptors(); 6844 maybe_new_map = CopyDropDescriptors();
6841 } else { 6845 } else {
(...skipping 9412 matching lines...) Expand 10 before | Expand all | Expand 10 after
16254 #define ERROR_MESSAGES_TEXTS(C, T) T, 16258 #define ERROR_MESSAGES_TEXTS(C, T) T,
16255 static const char* error_messages_[] = { 16259 static const char* error_messages_[] = {
16256 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16260 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16257 }; 16261 };
16258 #undef ERROR_MESSAGES_TEXTS 16262 #undef ERROR_MESSAGES_TEXTS
16259 return error_messages_[reason]; 16263 return error_messages_[reason];
16260 } 16264 }
16261 16265
16262 16266
16263 } } // namespace v8::internal 16267 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698