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

Side by Side Diff: src/objects.cc

Issue 23464089: Handlify JSObject::AllocateStorageForMap method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 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 3693 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 return Handle<Object>(); 3704 return Handle<Object>();
3705 } 3705 }
3706 trap = Handle<Object>(derived); 3706 trap = Handle<Object>(derived);
3707 } 3707 }
3708 3708
3709 bool threw; 3709 bool threw;
3710 return Execution::Call(isolate, trap, handler, argc, argv, &threw); 3710 return Execution::Call(isolate, trap, handler, argc, argv, &threw);
3711 } 3711 }
3712 3712
3713 3713
3714 // TODO(mstarzinger): Temporary wrapper until handlified.
3715 static Handle<Map> MapAsElementsKind(Handle<Map> map, ElementsKind kind) {
3716 CALL_HEAP_FUNCTION(map->GetIsolate(), map->AsElementsKind(kind), Map);
3717 }
3718
3719
3714 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { 3720 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
3715 CALL_HEAP_FUNCTION_VOID( 3721 ASSERT(object->map()->inobject_properties() == map->inobject_properties());
3716 object->GetIsolate(), 3722 ElementsKind obj_kind = object->map()->elements_kind();
3717 object->AllocateStorageForMap(*map)); 3723 ElementsKind map_kind = map->elements_kind();
3724 if (map_kind != obj_kind) {
3725 ElementsKind to_kind = map_kind;
3726 if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) ||
3727 IsDictionaryElementsKind(obj_kind)) {
3728 to_kind = obj_kind;
3729 }
3730 if (IsDictionaryElementsKind(to_kind)) {
3731 NormalizeElements(object);
3732 } else {
3733 TransitionElementsKind(object, to_kind);
3734 }
3735 map = MapAsElementsKind(map, to_kind);
3736 }
3737 int total_size =
3738 map->NumberOfOwnDescriptors() + map->unused_property_fields();
3739 int out_of_object = total_size - map->inobject_properties();
3740 if (out_of_object != object->properties()->length()) {
3741 Isolate* isolate = object->GetIsolate();
3742 Handle<FixedArray> new_properties = isolate->factory()->CopySizeFixedArray(
3743 handle(object->properties()), out_of_object);
3744 object->set_properties(*new_properties);
3745 }
3746 object->set_map(*map);
3718 } 3747 }
3719 3748
3720 3749
3721 void JSObject::MigrateInstance(Handle<JSObject> object) { 3750 void JSObject::MigrateInstance(Handle<JSObject> object) {
3722 // Converting any field to the most specific type will cause the 3751 // Converting any field to the most specific type will cause the
3723 // GeneralizeFieldRepresentation algorithm to create the most general existing 3752 // GeneralizeFieldRepresentation algorithm to create the most general existing
3724 // transition that matches the object. This achieves what is needed. 3753 // transition that matches the object. This achieves what is needed.
3725 Handle<Map> original_map(object->map()); 3754 Handle<Map> original_map(object->map());
3726 GeneralizeFieldRepresentation( 3755 GeneralizeFieldRepresentation(
3727 object, 0, Representation::None(), ALLOW_AS_CONSTANT); 3756 object, 0, Representation::None(), ALLOW_AS_CONSTANT);
(...skipping 8692 matching lines...) Expand 10 before | Expand all | Expand 10 after
12420 } 12449 }
12421 } 12450 }
12422 } 12451 }
12423 // All possible cases have been handled above. Add a return to avoid the 12452 // All possible cases have been handled above. Add a return to avoid the
12424 // complaints from the compiler. 12453 // complaints from the compiler.
12425 UNREACHABLE(); 12454 UNREACHABLE();
12426 return isolate->heap()->null_value(); 12455 return isolate->heap()->null_value();
12427 } 12456 }
12428 12457
12429 12458
12430 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, 12459 void JSObject::TransitionElementsKind(Handle<JSObject> object,
12431 ElementsKind to_kind) { 12460 ElementsKind to_kind) {
12432 CALL_HEAP_FUNCTION(object->GetIsolate(), 12461 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
12433 object->TransitionElementsKind(to_kind), 12462 object->TransitionElementsKind(to_kind));
12434 Object);
12435 } 12463 }
12436 12464
12437 12465
12438 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { 12466 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
12439 if (!FLAG_track_allocation_sites || !IsJSArray()) { 12467 if (!FLAG_track_allocation_sites || !IsJSArray()) {
12440 return this; 12468 return this;
12441 } 12469 }
12442 12470
12443 AllocationMemento* memento = AllocationMemento::FindForJSObject(this); 12471 AllocationMemento* memento = AllocationMemento::FindForJSObject(this);
12444 if (memento == NULL || !memento->IsValid()) { 12472 if (memento == NULL || !memento->IsValid()) {
(...skipping 3652 matching lines...) Expand 10 before | Expand all | Expand 10 after
16097 #define ERROR_MESSAGES_TEXTS(C, T) T, 16125 #define ERROR_MESSAGES_TEXTS(C, T) T,
16098 static const char* error_messages_[] = { 16126 static const char* error_messages_[] = {
16099 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16127 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16100 }; 16128 };
16101 #undef ERROR_MESSAGES_TEXTS 16129 #undef ERROR_MESSAGES_TEXTS
16102 return error_messages_[reason]; 16130 return error_messages_[reason];
16103 } 16131 }
16104 16132
16105 16133
16106 } } // namespace v8::internal 16134 } } // 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