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

Side by Side Diff: src/heap.cc

Issue 21285: Remove experimental ExternalSymbolCallback feature. This is not needed... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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
« no previous file with comments | « src/heap.h ('k') | src/heap-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 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // semispace_size_ should be a power of 2 and old_generation_size_ should be 78 // semispace_size_ should be a power of 2 and old_generation_size_ should be
79 // a multiple of Page::kPageSize. 79 // a multiple of Page::kPageSize.
80 int Heap::semispace_size_ = 2*MB; 80 int Heap::semispace_size_ = 2*MB;
81 int Heap::old_generation_size_ = 512*MB; 81 int Heap::old_generation_size_ = 512*MB;
82 int Heap::initial_semispace_size_ = 256*KB; 82 int Heap::initial_semispace_size_ = 256*KB;
83 83
84 GCCallback Heap::global_gc_prologue_callback_ = NULL; 84 GCCallback Heap::global_gc_prologue_callback_ = NULL;
85 GCCallback Heap::global_gc_epilogue_callback_ = NULL; 85 GCCallback Heap::global_gc_epilogue_callback_ = NULL;
86 86
87 ExternalSymbolCallback Heap::global_external_symbol_callback_ = NULL;
88
89 // Variables set based on semispace_size_ and old_generation_size_ in 87 // Variables set based on semispace_size_ and old_generation_size_ in
90 // ConfigureHeap. 88 // ConfigureHeap.
91 int Heap::young_generation_size_ = 0; // Will be 2 * semispace_size_. 89 int Heap::young_generation_size_ = 0; // Will be 2 * semispace_size_.
92 90
93 // Double the new space after this many scavenge collections. 91 // Double the new space after this many scavenge collections.
94 int Heap::new_space_growth_limit_ = 8; 92 int Heap::new_space_growth_limit_ = 8;
95 int Heap::scavenge_count_ = 0; 93 int Heap::scavenge_count_ = 0;
96 Heap::HeapState Heap::gc_state_ = NOT_IN_GC; 94 Heap::HeapState Heap::gc_state_ = NOT_IN_GC;
97 95
98 int Heap::mc_count_ = 0; 96 int Heap::mc_count_ = 0;
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 if (result->IsFailure()) return result; 1524 if (result->IsFailure()) return result;
1527 1525
1528 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); 1526 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result);
1529 external_string->set_length(length); 1527 external_string->set_length(length);
1530 external_string->set_resource(resource); 1528 external_string->set_resource(resource);
1531 1529
1532 return result; 1530 return result;
1533 } 1531 }
1534 1532
1535 1533
1536 Object* Heap::AllocateExternalSymbolFromTwoByte(
1537 ExternalTwoByteString::Resource* resource) {
1538 int length = resource->length();
1539
1540 Map* map = ExternalTwoByteString::SymbolMap(length);
1541 Object* result = Allocate(map, OLD_DATA_SPACE);
1542 if (result->IsFailure()) return result;
1543
1544 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result);
1545 external_string->set_length(length);
1546 external_string->set_resource(resource);
1547
1548 return result;
1549 }
1550
1551
1552 Object* Heap::LookupSingleCharacterStringFromCode(uint16_t code) { 1534 Object* Heap::LookupSingleCharacterStringFromCode(uint16_t code) {
1553 if (code <= String::kMaxAsciiCharCode) { 1535 if (code <= String::kMaxAsciiCharCode) {
1554 Object* value = Heap::single_character_string_cache()->get(code); 1536 Object* value = Heap::single_character_string_cache()->get(code);
1555 if (value != Heap::undefined_value()) return value; 1537 if (value != Heap::undefined_value()) return value;
1556 1538
1557 char buffer[1]; 1539 char buffer[1];
1558 buffer[0] = static_cast<char>(code); 1540 buffer[0] = static_cast<char>(code);
1559 Object* result = LookupSymbol(Vector<const char>(buffer, 1)); 1541 Object* result = LookupSymbol(Vector<const char>(buffer, 1));
1560 1542
1561 if (result->IsFailure()) return result; 1543 if (result->IsFailure()) return result;
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 } 2074 }
2093 2075
2094 2076
2095 Object* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, 2077 Object* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer,
2096 int chars, 2078 int chars,
2097 uint32_t length_field) { 2079 uint32_t length_field) {
2098 // Ensure the chars matches the number of characters in the buffer. 2080 // Ensure the chars matches the number of characters in the buffer.
2099 ASSERT(static_cast<unsigned>(chars) == buffer->Length()); 2081 ASSERT(static_cast<unsigned>(chars) == buffer->Length());
2100 // Determine whether the string is ascii. 2082 // Determine whether the string is ascii.
2101 bool is_ascii = true; 2083 bool is_ascii = true;
2102 while (buffer->has_more()) { 2084 while (buffer->has_more() && is_ascii) {
2103 if (buffer->GetNext() > unibrow::Utf8::kMaxOneByteChar) is_ascii = false; 2085 if (buffer->GetNext() > unibrow::Utf8::kMaxOneByteChar) is_ascii = false;
2104 } 2086 }
2105 buffer->Rewind(); 2087 buffer->Rewind();
2106 2088
2107 // Compute map and object size. 2089 // Compute map and object size.
2108 int size; 2090 int size;
2109 Map* map; 2091 Map* map;
2110 2092
2111 if (is_ascii) { 2093 if (is_ascii) {
2112 if (chars <= String::kMaxShortStringSize) { 2094 if (chars <= String::kMaxShortStringSize) {
(...skipping 30 matching lines...) Expand all
2143 ASSERT_EQ(size, answer->Size()); 2125 ASSERT_EQ(size, answer->Size());
2144 2126
2145 // Fill in the characters. 2127 // Fill in the characters.
2146 for (int i = 0; i < chars; i++) { 2128 for (int i = 0; i < chars; i++) {
2147 answer->Set(answer_shape, i, buffer->GetNext()); 2129 answer->Set(answer_shape, i, buffer->GetNext());
2148 } 2130 }
2149 return answer; 2131 return answer;
2150 } 2132 }
2151 2133
2152 2134
2153 // External string resource that only contains a length field. These
2154 // are used temporarily when allocating external symbols.
2155 class DummyExternalStringResource
2156 : public v8::String::ExternalStringResource {
2157 public:
2158 explicit DummyExternalStringResource(size_t length) : length_(length) { }
2159
2160 virtual const uint16_t* data() const {
2161 UNREACHABLE();
2162 return NULL;
2163 }
2164
2165 virtual size_t length() const { return length_; }
2166 private:
2167 size_t length_;
2168 };
2169
2170
2171 Object* Heap::AllocateExternalSymbol(Vector<const char> string, int chars) {
2172 // Attempt to allocate the resulting external string first. Use a
2173 // dummy string resource that has the correct length so that we only
2174 // have to patch the external string resource after the callback.
2175 DummyExternalStringResource dummy_resource(chars);
2176 Object* obj = AllocateExternalSymbolFromTwoByte(&dummy_resource);
2177 if (obj->IsFailure()) return obj;
2178 // Perform callback.
2179 v8::String::ExternalStringResource* resource =
2180 global_external_symbol_callback_(string.start(), string.length());
2181 // Patch the resource pointer of the result.
2182 ExternalTwoByteString* result = ExternalTwoByteString::cast(obj);
2183 result->set_resource(resource);
2184 // Force hash code to be computed.
2185 result->Hash();
2186 ASSERT(result->IsEqualTo(string));
2187 return result;
2188 }
2189
2190
2191 Object* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) { 2135 Object* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) {
2192 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; 2136 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE;
2193 int size = SeqAsciiString::SizeFor(length); 2137 int size = SeqAsciiString::SizeFor(length);
2194 if (size > MaxHeapObjectSize()) { 2138 if (size > MaxHeapObjectSize()) {
2195 space = LO_SPACE; 2139 space = LO_SPACE;
2196 } 2140 }
2197 2141
2198 // Use AllocateRaw rather than Allocate because the object's size cannot be 2142 // Use AllocateRaw rather than Allocate because the object's size cannot be
2199 // determined from the map. 2143 // determined from the map.
2200 Object* result = AllocateRaw(size, space, OLD_DATA_SPACE); 2144 Object* result = AllocateRaw(size, space, OLD_DATA_SPACE);
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 #ifdef DEBUG 3300 #ifdef DEBUG
3357 bool Heap::GarbageCollectionGreedyCheck() { 3301 bool Heap::GarbageCollectionGreedyCheck() {
3358 ASSERT(FLAG_gc_greedy); 3302 ASSERT(FLAG_gc_greedy);
3359 if (Bootstrapper::IsActive()) return true; 3303 if (Bootstrapper::IsActive()) return true;
3360 if (disallow_allocation_failure()) return true; 3304 if (disallow_allocation_failure()) return true;
3361 return CollectGarbage(0, NEW_SPACE); 3305 return CollectGarbage(0, NEW_SPACE);
3362 } 3306 }
3363 #endif 3307 #endif
3364 3308
3365 } } // namespace v8::internal 3309 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698