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

Side by Side Diff: src/heap.cc

Issue 8360004: Avoid incremental marking write-barrier when constructing descriptor arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3416 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 // cannot be constructed without having these properties. Guard by 3427 // cannot be constructed without having these properties. Guard by
3428 // the inline_new flag so we only change the map if we generate a 3428 // the inline_new flag so we only change the map if we generate a
3429 // specialized construct stub. 3429 // specialized construct stub.
3430 ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields); 3430 ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields);
3431 if (fun->shared()->CanGenerateInlineConstructor(prototype)) { 3431 if (fun->shared()->CanGenerateInlineConstructor(prototype)) {
3432 int count = fun->shared()->this_property_assignments_count(); 3432 int count = fun->shared()->this_property_assignments_count();
3433 if (count > in_object_properties) { 3433 if (count > in_object_properties) {
3434 // Inline constructor can only handle inobject properties. 3434 // Inline constructor can only handle inobject properties.
3435 fun->shared()->ForbidInlineConstructor(); 3435 fun->shared()->ForbidInlineConstructor();
3436 } else { 3436 } else {
3437 Object* descriptors_obj; 3437 DescriptorArray* descriptors;
3438 { MaybeObject* maybe_descriptors_obj = DescriptorArray::Allocate(count); 3438 { MaybeObject* maybe_descriptors_obj = DescriptorArray::Allocate(count);
3439 if (!maybe_descriptors_obj->ToObject(&descriptors_obj)) { 3439 if (!maybe_descriptors_obj->To<DescriptorArray>(&descriptors)) {
3440 return maybe_descriptors_obj; 3440 return maybe_descriptors_obj;
3441 } 3441 }
3442 } 3442 }
3443 DescriptorArray* descriptors = DescriptorArray::cast(descriptors_obj); 3443 DescriptorArray::WhitenessWitness witness(descriptors);
3444 for (int i = 0; i < count; i++) { 3444 for (int i = 0; i < count; i++) {
3445 String* name = fun->shared()->GetThisPropertyAssignmentName(i); 3445 String* name = fun->shared()->GetThisPropertyAssignmentName(i);
3446 ASSERT(name->IsSymbol()); 3446 ASSERT(name->IsSymbol());
3447 FieldDescriptor field(name, i, NONE); 3447 FieldDescriptor field(name, i, NONE);
3448 field.SetEnumerationIndex(i); 3448 field.SetEnumerationIndex(i);
3449 descriptors->Set(i, &field); 3449 descriptors->Set(i, &field, witness);
3450 } 3450 }
3451 descriptors->SetNextEnumerationIndex(count); 3451 descriptors->SetNextEnumerationIndex(count);
3452 descriptors->SortUnchecked(); 3452 descriptors->SortUnchecked(witness);
3453 3453
3454 // The descriptors may contain duplicates because the compiler does not 3454 // The descriptors may contain duplicates because the compiler does not
3455 // guarantee the uniqueness of property names (it would have required 3455 // guarantee the uniqueness of property names (it would have required
3456 // quadratic time). Once the descriptors are sorted we can check for 3456 // quadratic time). Once the descriptors are sorted we can check for
3457 // duplicates in linear time. 3457 // duplicates in linear time.
3458 if (HasDuplicates(descriptors)) { 3458 if (HasDuplicates(descriptors)) {
3459 fun->shared()->ForbidInlineConstructor(); 3459 fun->shared()->ForbidInlineConstructor();
3460 } else { 3460 } else {
3461 map->set_instance_descriptors(descriptors); 3461 map->set_instance_descriptors(descriptors);
3462 map->set_pre_allocated_property_fields(count); 3462 map->set_pre_allocated_property_fields(count);
(...skipping 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after
6396 isolate_->heap()->store_buffer()->Compact(); 6396 isolate_->heap()->store_buffer()->Compact();
6397 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6397 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6398 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6398 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6399 next = chunk->next_chunk(); 6399 next = chunk->next_chunk();
6400 isolate_->memory_allocator()->Free(chunk); 6400 isolate_->memory_allocator()->Free(chunk);
6401 } 6401 }
6402 chunks_queued_for_free_ = NULL; 6402 chunks_queued_for_free_ = NULL;
6403 } 6403 }
6404 6404
6405 } } // namespace v8::internal 6405 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/incremental-marking.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698