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

Side by Side Diff: src/objects.cc

Issue 32483006: Handlify Map::CopyNormalized (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cr changes Created 7 years, 1 month 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') | no next file » | 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 4455 matching lines...) Expand 10 before | Expand all | Expand 10 after
4466 } 4466 }
4467 if (pt->IsNull()) return ABSENT; 4467 if (pt->IsNull()) return ABSENT;
4468 return JSObject::cast(pt)->GetElementAttributeWithReceiver( 4468 return JSObject::cast(pt)->GetElementAttributeWithReceiver(
4469 receiver, index, true); 4469 receiver, index, true);
4470 } 4470 }
4471 4471
4472 4472
4473 Handle<Map> NormalizedMapCache::Get(Handle<NormalizedMapCache> cache, 4473 Handle<Map> NormalizedMapCache::Get(Handle<NormalizedMapCache> cache,
4474 Handle<JSObject> obj, 4474 Handle<JSObject> obj,
4475 PropertyNormalizationMode mode) { 4475 PropertyNormalizationMode mode) {
4476 Map* fast = obj->map(); 4476 int index = obj->map()->Hash() % kEntries;
4477 int index = fast->Hash() % kEntries; 4477 Handle<Object> result = handle(cache->get(index), cache->GetIsolate());
4478 Object* result = cache->get(index);
4479 if (result->IsMap() && 4478 if (result->IsMap() &&
4480 Map::cast(result)->EquivalentToForNormalization(fast, mode)) { 4479 Handle<Map>::cast(result)->EquivalentToForNormalization(obj->map(),
4480 mode)) {
4481 #ifdef VERIFY_HEAP 4481 #ifdef VERIFY_HEAP
4482 if (FLAG_verify_heap) { 4482 if (FLAG_verify_heap) {
4483 Map::cast(result)->SharedMapVerify(); 4483 Handle<Map>::cast(result)->SharedMapVerify();
4484 } 4484 }
4485 #endif 4485 #endif
4486 #ifdef DEBUG 4486 #ifdef DEBUG
4487 if (FLAG_enable_slow_asserts) { 4487 if (FLAG_enable_slow_asserts) {
4488 // The cached map should match newly created normalized map bit-by-bit, 4488 // The cached map should match newly created normalized map bit-by-bit,
4489 // except for the code cache, which can contain some ics which can be 4489 // except for the code cache, which can contain some ics which can be
4490 // applied to the shared map. 4490 // applied to the shared map.
4491 Object* fresh; 4491 Handle<Map> fresh = Map::CopyNormalized(handle(obj->map()), mode,
4492 MaybeObject* maybe_fresh = 4492 SHARED_NORMALIZED_MAP);
4493 fast->CopyNormalized(mode, SHARED_NORMALIZED_MAP); 4493
4494 if (maybe_fresh->ToObject(&fresh)) { 4494 ASSERT(memcmp(fresh->address(),
4495 ASSERT(memcmp(Map::cast(fresh)->address(), 4495 Handle<Map>::cast(result)->address(),
4496 Map::cast(result)->address(), 4496 Map::kCodeCacheOffset) == 0);
4497 Map::kCodeCacheOffset) == 0); 4497 STATIC_ASSERT(Map::kDependentCodeOffset ==
4498 STATIC_ASSERT(Map::kDependentCodeOffset == 4498 Map::kCodeCacheOffset + kPointerSize);
4499 Map::kCodeCacheOffset + kPointerSize); 4499 int offset = Map::kDependentCodeOffset + kPointerSize;
4500 int offset = Map::kDependentCodeOffset + kPointerSize; 4500 ASSERT(memcmp(fresh->address() + offset,
4501 ASSERT(memcmp(Map::cast(fresh)->address() + offset, 4501 Handle<Map>::cast(result)->address() + offset,
4502 Map::cast(result)->address() + offset, 4502 Map::kSize - offset) == 0);
4503 Map::kSize - offset) == 0);
4504 }
4505 } 4503 }
4506 #endif 4504 #endif
4507 return handle(Map::cast(result)); 4505 return Handle<Map>::cast(result);
4508 } 4506 }
4509 4507
4510 Isolate* isolate = cache->GetIsolate(); 4508 Isolate* isolate = cache->GetIsolate();
4511 Handle<Map> map = Map::CopyNormalized(handle(fast), mode, 4509 Handle<Map> map = Map::CopyNormalized(handle(obj->map()), mode,
4512 SHARED_NORMALIZED_MAP); 4510 SHARED_NORMALIZED_MAP);
4513 ASSERT(map->is_dictionary_map()); 4511 ASSERT(map->is_dictionary_map());
4514 cache->set(index, *map); 4512 cache->set(index, *map);
4515 isolate->counters()->normalized_maps()->Increment(); 4513 isolate->counters()->normalized_maps()->Increment();
4516 4514
4517 return map; 4515 return map;
4518 } 4516 }
4519 4517
4520 4518
4521 void NormalizedMapCache::Clear() { 4519 void NormalizedMapCache::Clear() {
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
6642 } 6640 }
6643 } 6641 }
6644 } 6642 }
6645 return GetHeap()->undefined_value(); 6643 return GetHeap()->undefined_value();
6646 } else { 6644 } else {
6647 return property_dictionary()->SlowReverseLookup(value); 6645 return property_dictionary()->SlowReverseLookup(value);
6648 } 6646 }
6649 } 6647 }
6650 6648
6651 6649
6650 Handle<Map> Map::RawCopy(Handle<Map> map,
6651 int instance_size) {
6652 CALL_HEAP_FUNCTION(map->GetIsolate(),
6653 map->RawCopy(instance_size),
6654 Map);
6655 }
6656
6657
6652 MaybeObject* Map::RawCopy(int instance_size) { 6658 MaybeObject* Map::RawCopy(int instance_size) {
6653 Map* result; 6659 Map* result;
6654 MaybeObject* maybe_result = 6660 MaybeObject* maybe_result =
6655 GetHeap()->AllocateMap(instance_type(), instance_size); 6661 GetHeap()->AllocateMap(instance_type(), instance_size);
6656 if (!maybe_result->To(&result)) return maybe_result; 6662 if (!maybe_result->To(&result)) return maybe_result;
6657 6663
6658 result->set_prototype(prototype()); 6664 result->set_prototype(prototype());
6659 result->set_constructor(constructor()); 6665 result->set_constructor(constructor());
6660 result->set_bit_field(bit_field()); 6666 result->set_bit_field(bit_field());
6661 result->set_bit_field2(bit_field2()); 6667 result->set_bit_field2(bit_field2());
6662 int new_bit_field3 = bit_field3(); 6668 int new_bit_field3 = bit_field3();
6663 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); 6669 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true);
6664 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); 6670 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0);
6665 new_bit_field3 = EnumLengthBits::update(new_bit_field3, kInvalidEnumCache); 6671 new_bit_field3 = EnumLengthBits::update(new_bit_field3, kInvalidEnumCache);
6666 new_bit_field3 = Deprecated::update(new_bit_field3, false); 6672 new_bit_field3 = Deprecated::update(new_bit_field3, false);
6667 new_bit_field3 = IsUnstable::update(new_bit_field3, false); 6673 new_bit_field3 = IsUnstable::update(new_bit_field3, false);
6668 result->set_bit_field3(new_bit_field3); 6674 result->set_bit_field3(new_bit_field3);
6669 return result; 6675 return result;
6670 } 6676 }
6671 6677
6672 6678
6673 Handle<Map> Map::CopyNormalized(Handle<Map> map, 6679 Handle<Map> Map::CopyNormalized(Handle<Map> map,
6674 PropertyNormalizationMode mode, 6680 PropertyNormalizationMode mode,
6675 NormalizedMapSharingMode sharing) { 6681 NormalizedMapSharingMode sharing) {
6676 CALL_HEAP_FUNCTION(map->GetIsolate(), 6682 int new_instance_size = map->instance_size();
6677 map->CopyNormalized(mode, sharing),
6678 Map);
6679 }
6680
6681
6682 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode,
6683 NormalizedMapSharingMode sharing) {
6684 int new_instance_size = instance_size();
6685 if (mode == CLEAR_INOBJECT_PROPERTIES) { 6683 if (mode == CLEAR_INOBJECT_PROPERTIES) {
6686 new_instance_size -= inobject_properties() * kPointerSize; 6684 new_instance_size -= map->inobject_properties() * kPointerSize;
6687 } 6685 }
6688 6686
6689 Map* result; 6687 Handle<Map> result = Map::RawCopy(map, new_instance_size);
6690 MaybeObject* maybe_result = RawCopy(new_instance_size);
6691 if (!maybe_result->To(&result)) return maybe_result;
6692 6688
6693 if (mode != CLEAR_INOBJECT_PROPERTIES) { 6689 if (mode != CLEAR_INOBJECT_PROPERTIES) {
6694 result->set_inobject_properties(inobject_properties()); 6690 result->set_inobject_properties(map->inobject_properties());
6695 } 6691 }
6696 6692
6697 result->set_is_shared(sharing == SHARED_NORMALIZED_MAP); 6693 result->set_is_shared(sharing == SHARED_NORMALIZED_MAP);
6698 result->set_dictionary_map(true); 6694 result->set_dictionary_map(true);
6699 result->set_migration_target(false); 6695 result->set_migration_target(false);
6700 6696
6701 #ifdef VERIFY_HEAP 6697 #ifdef VERIFY_HEAP
6702 if (FLAG_verify_heap && result->is_shared()) { 6698 if (FLAG_verify_heap && result->is_shared()) {
6703 result->SharedMapVerify(); 6699 result->SharedMapVerify();
6704 } 6700 }
(...skipping 9681 matching lines...) Expand 10 before | Expand all | Expand 10 after
16386 #define ERROR_MESSAGES_TEXTS(C, T) T, 16382 #define ERROR_MESSAGES_TEXTS(C, T) T,
16387 static const char* error_messages_[] = { 16383 static const char* error_messages_[] = {
16388 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16384 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16389 }; 16385 };
16390 #undef ERROR_MESSAGES_TEXTS 16386 #undef ERROR_MESSAGES_TEXTS
16391 return error_messages_[reason]; 16387 return error_messages_[reason];
16392 } 16388 }
16393 16389
16394 16390
16395 } } // namespace v8::internal 16391 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698