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

Side by Side Diff: src/objects.cc

Issue 12224035: Generalize map dependent codes array to allow multiple dependency groups. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 9483 matching lines...) Expand 10 before | Expand all | Expand 10 after
9494 9494
9495 9495
9496 void Map::ZapPrototypeTransitions() { 9496 void Map::ZapPrototypeTransitions() {
9497 FixedArray* proto_transitions = GetPrototypeTransitions(); 9497 FixedArray* proto_transitions = GetPrototypeTransitions();
9498 MemsetPointer(proto_transitions->data_start(), 9498 MemsetPointer(proto_transitions->data_start(),
9499 GetHeap()->the_hole_value(), 9499 GetHeap()->the_hole_value(),
9500 proto_transitions->length()); 9500 proto_transitions->length());
9501 } 9501 }
9502 9502
9503 9503
9504 Handle<DependentCodes> DependentCodes::Append(Handle<DependentCodes> codes, 9504 Handle<DependentCodes> DependentCodes::Insert(Handle<DependentCodes> codes,
9505 DependencyGroup group,
9505 Handle<Code> value) { 9506 Handle<Code> value) {
9506 int append_index = codes->number_of_codes(); 9507 GroupStartIndexes starts;
9507 if (append_index > 0 && codes->code_at(append_index - 1) == *value) { 9508 codes->ComputeGroupStartIndexes(starts);
9509 int start = starts[group];
9510 int end = starts[group + 1];
9511 int number_of_codes = starts[kGroupCount];
9512 if (start < end && codes->code_at(end - 1) == *value) {
9508 // Do not append the code if it is already in the array. 9513 // Do not append the code if it is already in the array.
9509 // It is sufficient to just check only the last element because 9514 // It is sufficient to just check only the last element because
9510 // we process embedded maps of an optimized code in one batch. 9515 // we process embedded maps of an optimized code in one batch.
9511 return codes; 9516 return codes;
9512 } 9517 }
9513 if (codes->length() < kCodesIndex + append_index + 1) { 9518 if (codes->length() < kCodesStartIndex + number_of_codes + 1) {
9514 Factory* factory = codes->GetIsolate()->factory(); 9519 Factory* factory = codes->GetIsolate()->factory();
9515 int capacity = kCodesIndex + append_index + 1; 9520 int capacity = kCodesStartIndex + number_of_codes + 1;
9516 if (capacity > 5) capacity = capacity * 5 / 4; 9521 if (capacity > 5) capacity = capacity * 5 / 4;
9517 Handle<DependentCodes> new_codes = Handle<DependentCodes>::cast( 9522 Handle<DependentCodes> new_codes = Handle<DependentCodes>::cast(
9518 factory->CopySizeFixedArray(codes, capacity)); 9523 factory->CopySizeFixedArray(codes, capacity));
9519 // The number of codes can change after GC. 9524 // The number of codes can change after GC.
9520 append_index = codes->number_of_codes(); 9525 codes->ComputeGroupStartIndexes(starts);
9521 for (int i = 0; i < append_index; i++) { 9526 start = starts[group];
9527 end = starts[group + 1];
9528 number_of_codes = starts[kGroupCount];
9529 for (int i = 0; i < number_of_codes; i++) {
9522 codes->clear_code_at(i); 9530 codes->clear_code_at(i);
9523 } 9531 }
9532 // If the old fixed array was empty, we need to reset counters of the
9533 // new array.
9534 if (number_of_codes == 0) {
9535 for (int g = 0; g < kGroupCount; g++) {
9536 new_codes->set_number_of_codes(static_cast<DependencyGroup>(g), 0);
9537 }
9538 }
9524 codes = new_codes; 9539 codes = new_codes;
9525 } 9540 }
9526 codes->set_code_at(append_index, *value); 9541 codes->ExtendGroup(group);
9527 codes->set_number_of_codes(append_index + 1); 9542 codes->set_code_at(end, *value);
9543 codes->set_number_of_codes(group, end + 1 - start);
9528 return codes; 9544 return codes;
9529 } 9545 }
9530 9546
9531 9547
9532 bool DependentCodes::Contains(Code* code) { 9548 bool DependentCodes::Contains(DependencyGroup group, Code* code) {
9533 int limit = number_of_codes(); 9549 GroupStartIndexes starts;
9534 for (int i = 0; i < limit; i++) { 9550 ComputeGroupStartIndexes(starts);
9551 int number_of_codes = starts[kGroupCount];
9552 for (int i = 0; i < number_of_codes; i++) {
9535 if (code_at(i) == code) return true; 9553 if (code_at(i) == code) return true;
9536 } 9554 }
9537 return false; 9555 return false;
9538 } 9556 }
9539 9557
9540 9558
9541 MaybeObject* JSReceiver::SetPrototype(Object* value, 9559 MaybeObject* JSReceiver::SetPrototype(Object* value,
9542 bool skip_hidden_prototypes) { 9560 bool skip_hidden_prototypes) {
9543 #ifdef DEBUG 9561 #ifdef DEBUG
9544 int size = Size(); 9562 int size = Size();
(...skipping 4347 matching lines...) Expand 10 before | Expand all | Expand 10 after
13892 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13910 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13893 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13911 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13894 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13912 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13895 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13913 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13896 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13914 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13897 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13915 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13898 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13916 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13899 } 13917 }
13900 13918
13901 } } // namespace v8::internal 13919 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698