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

Side by Side Diff: src/objects.cc

Issue 11575007: Make embedded maps in optimized code weak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test that reproduces memleak and rebase. Created 7 years, 11 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 9462 matching lines...) Expand 10 before | Expand all | Expand 10 after
9473 9473
9474 9474
9475 void Map::ZapPrototypeTransitions() { 9475 void Map::ZapPrototypeTransitions() {
9476 FixedArray* proto_transitions = GetPrototypeTransitions(); 9476 FixedArray* proto_transitions = GetPrototypeTransitions();
9477 MemsetPointer(proto_transitions->data_start(), 9477 MemsetPointer(proto_transitions->data_start(),
9478 GetHeap()->the_hole_value(), 9478 GetHeap()->the_hole_value(),
9479 proto_transitions->length()); 9479 proto_transitions->length());
9480 } 9480 }
9481 9481
9482 9482
9483 Handle<DependentCodes> DependentCodes::Append(Handle<DependentCodes> codes,
9484 Handle<Code> value) {
9485 int append_index = codes->number_of_codes();
9486 if (append_index > 0 && codes->code_at(append_index - 1) == *value) {
9487 // Do not append the code if it is already in the array.
9488 // It is sufficient to just check only the last element because
9489 // we process embedded maps of an optimized code in one batch.
9490 return codes;
9491 }
9492 if (codes->length() < kCodesOffset + append_index + 1) {
9493 Factory* factory = codes->GetIsolate()->factory();
9494 int capacity = kCodesOffset + append_index + 1;
9495 if (capacity > 5) capacity = capacity * 5 / 4;
9496 Handle<DependentCodes> new_codes =
9497 Handle<DependentCodes>::cast(factory->NewFixedArray(capacity));
9498 // The number of codes can change after GC.
9499 append_index = codes->number_of_codes();
9500 new_codes->set_number_of_codes(append_index + 1);
9501 for (int i = 0; i < append_index; i++) {
9502 new_codes->set_code_at(i, codes->code_at(i));
9503 codes->clear_code_at(i);
9504 }
9505 new_codes->set_code_at(append_index, *value);
9506 for (int i = append_index + 1; kCodesOffset + i < capacity; i++) {
9507 new_codes->clear_code_at(i);
9508 }
9509 return new_codes;
9510 }
9511 codes->set_code_at(append_index, *value);
9512 codes->set_number_of_codes(append_index + 1);
9513 return codes;
9514 }
9515
9516
9483 MaybeObject* JSReceiver::SetPrototype(Object* value, 9517 MaybeObject* JSReceiver::SetPrototype(Object* value,
9484 bool skip_hidden_prototypes) { 9518 bool skip_hidden_prototypes) {
9485 #ifdef DEBUG 9519 #ifdef DEBUG
9486 int size = Size(); 9520 int size = Size();
9487 #endif 9521 #endif
9488 9522
9489 Heap* heap = GetHeap(); 9523 Heap* heap = GetHeap();
9490 // Silently ignore the change if value is not a JSObject or null. 9524 // Silently ignore the change if value is not a JSObject or null.
9491 // SpiderMonkey behaves this way. 9525 // SpiderMonkey behaves this way.
9492 if (!value->IsJSReceiver() && !value->IsNull()) return value; 9526 if (!value->IsJSReceiver() && !value->IsNull()) return value;
(...skipping 4334 matching lines...) Expand 10 before | Expand all | Expand 10 after
13827 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13861 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13828 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13862 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13829 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13863 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13830 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13864 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13831 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13865 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13832 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13866 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13833 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13867 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13834 } 13868 }
13835 13869
13836 } } // namespace v8::internal 13870 } } // namespace v8::internal
OLDNEW
« src/mark-compact.cc ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698