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

Side by Side Diff: src/factory.cc

Issue 257633002: HashTable::New() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/factory.h ('k') | src/heap.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "factory.h" 5 #include "factory.h"
6 6
7 #include "macro-assembler.h" 7 #include "macro-assembler.h"
8 #include "isolate-inl.h" 8 #include "isolate-inl.h"
9 #include "v8conversions.h" 9 #include "v8conversions.h"
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 Handle<OrderedHashSet> Factory::NewOrderedHashSet() { 134 Handle<OrderedHashSet> Factory::NewOrderedHashSet() {
135 return OrderedHashSet::Allocate(isolate(), 4); 135 return OrderedHashSet::Allocate(isolate(), 4);
136 } 136 }
137 137
138 138
139 Handle<OrderedHashMap> Factory::NewOrderedHashMap() { 139 Handle<OrderedHashMap> Factory::NewOrderedHashMap() {
140 return OrderedHashMap::Allocate(isolate(), 4); 140 return OrderedHashMap::Allocate(isolate(), 4);
141 } 141 }
142 142
143 143
144 Handle<ObjectHashTable> Factory::NewObjectHashTable(
145 int at_least_space_for,
146 MinimumCapacity capacity_option) {
147 ASSERT(0 <= at_least_space_for);
148 CALL_HEAP_FUNCTION(isolate(),
149 ObjectHashTable::Allocate(isolate()->heap(),
150 at_least_space_for,
151 capacity_option),
152 ObjectHashTable);
153 }
154
155
156 Handle<WeakHashTable> Factory::NewWeakHashTable(int at_least_space_for) {
157 ASSERT(0 <= at_least_space_for);
158 CALL_HEAP_FUNCTION(
159 isolate(),
160 WeakHashTable::Allocate(isolate()->heap(),
161 at_least_space_for,
162 USE_DEFAULT_MINIMUM_CAPACITY,
163 TENURED),
164 WeakHashTable);
165 }
166
167
168 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData( 144 Handle<DeoptimizationInputData> Factory::NewDeoptimizationInputData(
169 int deopt_entry_count, 145 int deopt_entry_count,
170 PretenureFlag pretenure) { 146 PretenureFlag pretenure) {
171 ASSERT(deopt_entry_count > 0); 147 ASSERT(deopt_entry_count > 0);
172 CALL_HEAP_FUNCTION(isolate(), 148 CALL_HEAP_FUNCTION(isolate(),
173 DeoptimizationInputData::Allocate(isolate(), 149 DeoptimizationInputData::Allocate(isolate(),
174 deopt_entry_count, 150 deopt_entry_count,
175 pretenure), 151 pretenure),
176 DeoptimizationInputData); 152 DeoptimizationInputData);
177 } 153 }
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after
2194 for (int i = 0; i < valid_descriptors; i++) { 2170 for (int i = 0; i < valid_descriptors; i++) {
2195 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i))); 2171 Handle<AccessorInfo> accessor(AccessorInfo::cast(array->get(i)));
2196 JSObject::SetAccessor(result, accessor).Assert(); 2172 JSObject::SetAccessor(result, accessor).Assert();
2197 } 2173 }
2198 2174
2199 ASSERT(result->shared()->IsApiFunction()); 2175 ASSERT(result->shared()->IsApiFunction());
2200 return result; 2176 return result;
2201 } 2177 }
2202 2178
2203 2179
2204 Handle<MapCache> Factory::NewMapCache(int at_least_space_for) {
2205 CALL_HEAP_FUNCTION(isolate(),
2206 MapCache::Allocate(isolate()->heap(),
2207 at_least_space_for),
2208 MapCache);
2209 }
2210
2211
2212 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context, 2180 Handle<MapCache> Factory::AddToMapCache(Handle<Context> context,
2213 Handle<FixedArray> keys, 2181 Handle<FixedArray> keys,
2214 Handle<Map> map) { 2182 Handle<Map> map) {
2215 Handle<MapCache> map_cache = handle(MapCache::cast(context->map_cache())); 2183 Handle<MapCache> map_cache = handle(MapCache::cast(context->map_cache()));
2216 Handle<MapCache> result = MapCache::Put(map_cache, keys, map); 2184 Handle<MapCache> result = MapCache::Put(map_cache, keys, map);
2217 context->set_map_cache(*result); 2185 context->set_map_cache(*result);
2218 return result; 2186 return result;
2219 } 2187 }
2220 2188
2221 2189
2222 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, 2190 Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context,
2223 Handle<FixedArray> keys) { 2191 Handle<FixedArray> keys) {
2224 if (context->map_cache()->IsUndefined()) { 2192 if (context->map_cache()->IsUndefined()) {
2225 // Allocate the new map cache for the native context. 2193 // Allocate the new map cache for the native context.
2226 Handle<MapCache> new_cache = NewMapCache(24); 2194 Handle<MapCache> new_cache = MapCache::New(isolate(), 24);
2227 context->set_map_cache(*new_cache); 2195 context->set_map_cache(*new_cache);
2228 } 2196 }
2229 // Check to see whether there is a matching element in the cache. 2197 // Check to see whether there is a matching element in the cache.
2230 Handle<MapCache> cache = 2198 Handle<MapCache> cache =
2231 Handle<MapCache>(MapCache::cast(context->map_cache())); 2199 Handle<MapCache>(MapCache::cast(context->map_cache()));
2232 Handle<Object> result = Handle<Object>(cache->Lookup(*keys), isolate()); 2200 Handle<Object> result = Handle<Object>(cache->Lookup(*keys), isolate());
2233 if (result->IsMap()) return Handle<Map>::cast(result); 2201 if (result->IsMap()) return Handle<Map>::cast(result);
2234 // Create a new map and add it to the cache. 2202 // Create a new map and add it to the cache.
2235 Handle<Map> map = Map::Create( 2203 Handle<Map> map = Map::Create(
2236 handle(context->object_function()), keys->length()); 2204 handle(context->object_function()), keys->length());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 return Handle<Object>::null(); 2265 return Handle<Object>::null();
2298 } 2266 }
2299 2267
2300 2268
2301 Handle<Object> Factory::ToBoolean(bool value) { 2269 Handle<Object> Factory::ToBoolean(bool value) {
2302 return value ? true_value() : false_value(); 2270 return value ? true_value() : false_value();
2303 } 2271 }
2304 2272
2305 2273
2306 } } // namespace v8::internal 2274 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698