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

Side by Side Diff: src/objects.cc

Issue 23818005: Handlify JSObject::EnsureCanContainHeapObjectElements 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 4440 matching lines...) Expand 10 before | Expand all | Expand 10 after
4451 int entries = length(); 4451 int entries = length();
4452 for (int i = 0; i != entries; i++) { 4452 for (int i = 0; i != entries; i++) {
4453 set_undefined(i); 4453 set_undefined(i);
4454 } 4454 }
4455 } 4455 }
4456 4456
4457 4457
4458 void JSObject::UpdateMapCodeCache(Handle<JSObject> object, 4458 void JSObject::UpdateMapCodeCache(Handle<JSObject> object,
4459 Handle<Name> name, 4459 Handle<Name> name,
4460 Handle<Code> code) { 4460 Handle<Code> code) {
4461 Isolate* isolate = object->GetIsolate(); 4461 Handle<Map> map(object->map());
4462 CALL_HEAP_FUNCTION_VOID(isolate, 4462 if (map->is_shared()) {
4463 object->UpdateMapCodeCache(*name, *code)); 4463 // Fast case maps are never marked as shared.
4464 ASSERT(!object->HasFastProperties());
4465 // Replace the map with an identical copy that can be safely modified.
4466 map = Map::CopyNormalized(map, KEEP_INOBJECT_PROPERTIES,
4467 UNIQUE_NORMALIZED_MAP);
4468 object->GetIsolate()->counters()->normalized_maps()->Increment();
4469 object->set_map(*map);
4470 }
4471 Map::UpdateCodeCache(map, name, code);
4464 } 4472 }
4465 4473
4466 4474
4467 MaybeObject* JSObject::UpdateMapCodeCache(Name* name, Code* code) {
4468 if (map()->is_shared()) {
4469 // Fast case maps are never marked as shared.
4470 ASSERT(!HasFastProperties());
4471 // Replace the map with an identical copy that can be safely modified.
4472 Object* obj;
4473 { MaybeObject* maybe_obj = map()->CopyNormalized(KEEP_INOBJECT_PROPERTIES,
4474 UNIQUE_NORMALIZED_MAP);
4475 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
4476 }
4477 GetIsolate()->counters()->normalized_maps()->Increment();
4478
4479 set_map(Map::cast(obj));
4480 }
4481 return map()->UpdateCodeCache(name, code);
4482 }
4483
4484
4485 void JSObject::NormalizeProperties(Handle<JSObject> object, 4475 void JSObject::NormalizeProperties(Handle<JSObject> object,
4486 PropertyNormalizationMode mode, 4476 PropertyNormalizationMode mode,
4487 int expected_additional_properties) { 4477 int expected_additional_properties) {
4488 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), 4478 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
4489 object->NormalizeProperties( 4479 object->NormalizeProperties(
4490 mode, expected_additional_properties)); 4480 mode, expected_additional_properties));
4491 } 4481 }
4492 4482
4493 4483
4494 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode, 4484 MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
6503 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true); 6493 new_bit_field3 = OwnsDescriptors::update(new_bit_field3, true);
6504 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0); 6494 new_bit_field3 = NumberOfOwnDescriptorsBits::update(new_bit_field3, 0);
6505 new_bit_field3 = EnumLengthBits::update(new_bit_field3, kInvalidEnumCache); 6495 new_bit_field3 = EnumLengthBits::update(new_bit_field3, kInvalidEnumCache);
6506 new_bit_field3 = Deprecated::update(new_bit_field3, false); 6496 new_bit_field3 = Deprecated::update(new_bit_field3, false);
6507 new_bit_field3 = IsUnstable::update(new_bit_field3, false); 6497 new_bit_field3 = IsUnstable::update(new_bit_field3, false);
6508 result->set_bit_field3(new_bit_field3); 6498 result->set_bit_field3(new_bit_field3);
6509 return result; 6499 return result;
6510 } 6500 }
6511 6501
6512 6502
6503 Handle<Map> Map::CopyNormalized(Handle<Map> map,
6504 PropertyNormalizationMode mode,
6505 NormalizedMapSharingMode sharing) {
6506 CALL_HEAP_FUNCTION(map->GetIsolate(),
6507 map->CopyNormalized(mode, sharing),
6508 Map);
6509 }
6510
6511
6513 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode, 6512 MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode,
6514 NormalizedMapSharingMode sharing) { 6513 NormalizedMapSharingMode sharing) {
6515 int new_instance_size = instance_size(); 6514 int new_instance_size = instance_size();
6516 if (mode == CLEAR_INOBJECT_PROPERTIES) { 6515 if (mode == CLEAR_INOBJECT_PROPERTIES) {
6517 new_instance_size -= inobject_properties() * kPointerSize; 6516 new_instance_size -= inobject_properties() * kPointerSize;
6518 } 6517 }
6519 6518
6520 Map* result; 6519 Map* result;
6521 MaybeObject* maybe_result = RawCopy(new_instance_size); 6520 MaybeObject* maybe_result = RawCopy(new_instance_size);
6522 if (!maybe_result->To(&result)) return maybe_result; 6521 if (!maybe_result->To(&result)) return maybe_result;
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after
9516 if (shared_info->optimization_disabled()) return false; 9515 if (shared_info->optimization_disabled()) return false;
9517 Code* code = shared_info->code(); 9516 Code* code = shared_info->code();
9518 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; 9517 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true;
9519 // If we never ran this (unlikely) then lets try to optimize it. 9518 // If we never ran this (unlikely) then lets try to optimize it.
9520 if (code->kind() != Code::FUNCTION) return true; 9519 if (code->kind() != Code::FUNCTION) return true;
9521 return code->optimizable(); 9520 return code->optimizable();
9522 } 9521 }
9523 9522
9524 9523
9525 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { 9524 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) {
9526 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), object->OptimizeAsPrototype()); 9525 if (object->IsGlobalObject()) return;
9526
9527 // Make sure prototypes are fast objects and their maps have the bit set
9528 // so they remain fast.
9529 if (!object->HasFastProperties()) {
9530 TransformToFastProperties(object, 0);
9531 }
9527 } 9532 }
9528 9533
9529 9534
9530 MaybeObject* JSObject::OptimizeAsPrototype() {
9531 if (IsGlobalObject()) return this;
9532
9533 // Make sure prototypes are fast objects and their maps have the bit set
9534 // so they remain fast.
9535 if (!HasFastProperties()) {
9536 MaybeObject* new_proto = TransformToFastProperties(0);
9537 if (new_proto->IsFailure()) return new_proto;
9538 ASSERT(new_proto == this);
9539 }
9540 return this;
9541 }
9542
9543
9544 static MUST_USE_RESULT MaybeObject* CacheInitialJSArrayMaps( 9535 static MUST_USE_RESULT MaybeObject* CacheInitialJSArrayMaps(
9545 Context* native_context, Map* initial_map) { 9536 Context* native_context, Map* initial_map) {
9546 // Replace all of the cached initial array maps in the native context with 9537 // Replace all of the cached initial array maps in the native context with
9547 // the appropriate transitioned elements kind maps. 9538 // the appropriate transitioned elements kind maps.
9548 Heap* heap = native_context->GetHeap(); 9539 Heap* heap = native_context->GetHeap();
9549 MaybeObject* maybe_maps = 9540 MaybeObject* maybe_maps =
9550 heap->AllocateFixedArrayWithHoles(kElementsKindCount, TENURED); 9541 heap->AllocateFixedArrayWithHoles(kElementsKindCount, TENURED);
9551 FixedArray* maps; 9542 FixedArray* maps;
9552 if (!maybe_maps->To(&maps)) return maybe_maps; 9543 if (!maybe_maps->To(&maps)) return maybe_maps;
9553 9544
(...skipping 6494 matching lines...) Expand 10 before | Expand all | Expand 10 after
16048 #define ERROR_MESSAGES_TEXTS(C, T) T, 16039 #define ERROR_MESSAGES_TEXTS(C, T) T,
16049 static const char* error_messages_[] = { 16040 static const char* error_messages_[] = {
16050 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16041 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16051 }; 16042 };
16052 #undef ERROR_MESSAGES_TEXTS 16043 #undef ERROR_MESSAGES_TEXTS
16053 return error_messages_[reason]; 16044 return error_messages_[reason];
16054 } 16045 }
16055 16046
16056 16047
16057 } } // namespace v8::internal 16048 } } // 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