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

Side by Side Diff: src/heap-inl.h

Issue 467037: External string table. (Closed)
Patch Set: Created 11 years 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 Object* Heap::NumberFromUint32(uint32_t value) { 103 Object* Heap::NumberFromUint32(uint32_t value) {
104 if ((int32_t)value >= 0 && Smi::IsValid((int32_t)value)) { 104 if ((int32_t)value >= 0 && Smi::IsValid((int32_t)value)) {
105 return Smi::FromInt((int32_t)value); 105 return Smi::FromInt((int32_t)value);
106 } 106 }
107 // Bypass NumberFromDouble to avoid various redundant checks. 107 // Bypass NumberFromDouble to avoid various redundant checks.
108 return AllocateHeapNumber(FastUI2D(value)); 108 return AllocateHeapNumber(FastUI2D(value));
109 } 109 }
110 110
111 111
112 void Heap::FinalizeExternalString(String* string) {
113 ASSERT(string->IsExternalString());
114 v8::String::ExternalStringResourceBase** resource_addr =
115 reinterpret_cast<v8::String::ExternalStringResourceBase**>(
116 reinterpret_cast<byte*>(string) +
117 ExternalString::kResourceOffset -
118 kHeapObjectTag);
119 delete *resource_addr;
120 // Clear the resource pointer in the string.
121 *resource_addr = NULL;
122 }
123
124
112 Object* Heap::AllocateRawMap() { 125 Object* Heap::AllocateRawMap() {
113 #ifdef DEBUG 126 #ifdef DEBUG
114 Counters::objs_since_last_full.Increment(); 127 Counters::objs_since_last_full.Increment();
115 Counters::objs_since_last_young.Increment(); 128 Counters::objs_since_last_young.Increment();
116 #endif 129 #endif
117 Object* result = map_space_->AllocateRaw(Map::kSize); 130 Object* result = map_space_->AllocateRaw(Map::kSize);
118 if (result->IsFailure()) old_gen_exhausted_ = true; 131 if (result->IsFailure()) old_gen_exhausted_ = true;
119 return result; 132 return result;
120 } 133 }
121 134
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 327
315 inline bool Heap::allow_allocation(bool new_state) { 328 inline bool Heap::allow_allocation(bool new_state) {
316 bool old = allocation_allowed_; 329 bool old = allocation_allowed_;
317 allocation_allowed_ = new_state; 330 allocation_allowed_ = new_state;
318 return old; 331 return old;
319 } 332 }
320 333
321 #endif 334 #endif
322 335
323 336
337 void ExternalStringTable::AddString(String* string) {
338 ASSERT(string->IsExternalString());
339 if (Heap::InNewSpace(string)) {
340 new_space_strings_.Add(string);
341 } else {
342 old_space_strings_.Add(string);
343 }
344 }
345
346
347 void ExternalStringTable::Iterate(ObjectVisitor* v) {
348 if (!new_space_strings_.is_empty()) {
349 Object** start = &new_space_strings_[0];
350 v->VisitPointers(start, start + new_space_strings_.length());
351 }
352 if (!old_space_strings_.is_empty()) {
353 Object** start = &old_space_strings_[0];
354 v->VisitPointers(start, start + old_space_strings_.length());
355 }
356 }
357
358
359 // Verify() is inline to avoid ifdef-s around its calls in release
360 // mode.
361 void ExternalStringTable::Verify() {
362 #ifdef DEBUG
363 for (int i = 0; i < new_space_strings_.length(); ++i) {
364 ASSERT(Heap::InNewSpace(new_space_strings_[i]));
365 ASSERT(new_space_strings_[i] != Heap::raw_unchecked_null_value());
366 }
367 for (int i = 0; i < old_space_strings_.length(); ++i) {
368 ASSERT(!Heap::InNewSpace(old_space_strings_[i]));
369 ASSERT(old_space_strings_[i] != Heap::raw_unchecked_null_value());
370 }
371 #endif
372 }
373
374
375 void ExternalStringTable::AddOldString(String* string) {
376 ASSERT(string->IsExternalString());
377 ASSERT(!Heap::InNewSpace(string));
378 old_space_strings_.Add(string);
379 }
380
381
382 void ExternalStringTable::ShrinkNewStrings(int position) {
383 new_space_strings_.Rewind(position);
384 Verify();
385 }
386
324 } } // namespace v8::internal 387 } } // namespace v8::internal
325 388
326 #endif // V8_HEAP_INL_H_ 389 #endif // V8_HEAP_INL_H_
OLDNEW
« src/heap.cc ('K') | « src/heap.cc ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698