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

Side by Side Diff: src/factory.cc

Issue 2028983002: Introduce IsUndefined(Isolate*) and IsTheHole(Isolate*) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixing wrongly wrapped lines Created 4 years, 6 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
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 "src/factory.h" 5 #include "src/factory.h"
6 6
7 #include "src/allocation-site-scopes.h" 7 #include "src/allocation-site-scopes.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 } 1229 }
1230 1230
1231 1231
1232 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, 1232 Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
1233 Handle<String> name, 1233 Handle<String> name,
1234 MaybeHandle<Code> code) { 1234 MaybeHandle<Code> code) {
1235 Handle<Context> context(isolate()->native_context()); 1235 Handle<Context> context(isolate()->native_context());
1236 Handle<SharedFunctionInfo> info = 1236 Handle<SharedFunctionInfo> info =
1237 NewSharedFunctionInfo(name, code, map->is_constructor()); 1237 NewSharedFunctionInfo(name, code, map->is_constructor());
1238 DCHECK(is_sloppy(info->language_mode())); 1238 DCHECK(is_sloppy(info->language_mode()));
1239 DCHECK(!map->IsUndefined()); 1239 DCHECK(!map->IsUndefined(isolate()));
1240 DCHECK( 1240 DCHECK(
1241 map.is_identical_to(isolate()->sloppy_function_map()) || 1241 map.is_identical_to(isolate()->sloppy_function_map()) ||
1242 map.is_identical_to(isolate()->sloppy_function_without_prototype_map()) || 1242 map.is_identical_to(isolate()->sloppy_function_without_prototype_map()) ||
1243 map.is_identical_to( 1243 map.is_identical_to(
1244 isolate()->sloppy_function_with_readonly_prototype_map()) || 1244 isolate()->sloppy_function_with_readonly_prototype_map()) ||
1245 map.is_identical_to(isolate()->strict_function_map()) || 1245 map.is_identical_to(isolate()->strict_function_map()) ||
1246 map.is_identical_to(isolate()->strict_function_without_prototype_map()) || 1246 map.is_identical_to(isolate()->strict_function_without_prototype_map()) ||
1247 // TODO(titzer): wasm_function_map() could be undefined here. ugly. 1247 // TODO(titzer): wasm_function_map() could be undefined here. ugly.
1248 (*map == context->get(Context::WASM_FUNCTION_MAP_INDEX)) || 1248 (*map == context->get(Context::WASM_FUNCTION_MAP_INDEX)) ||
1249 map.is_identical_to(isolate()->proxy_function_map())); 1249 map.is_identical_to(isolate()->proxy_function_map()));
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 number_string_cache()->set(hash * 2, *number); 2209 number_string_cache()->set(hash * 2, *number);
2210 number_string_cache()->set(hash * 2 + 1, *string); 2210 number_string_cache()->set(hash * 2 + 1, *string);
2211 } 2211 }
2212 2212
2213 2213
2214 Handle<String> Factory::NumberToString(Handle<Object> number, 2214 Handle<String> Factory::NumberToString(Handle<Object> number,
2215 bool check_number_string_cache) { 2215 bool check_number_string_cache) {
2216 isolate()->counters()->number_to_string_runtime()->Increment(); 2216 isolate()->counters()->number_to_string_runtime()->Increment();
2217 if (check_number_string_cache) { 2217 if (check_number_string_cache) {
2218 Handle<Object> cached = GetNumberStringCache(number); 2218 Handle<Object> cached = GetNumberStringCache(number);
2219 if (!cached->IsUndefined()) return Handle<String>::cast(cached); 2219 if (!cached->IsUndefined(isolate())) return Handle<String>::cast(cached);
2220 } 2220 }
2221 2221
2222 char arr[100]; 2222 char arr[100];
2223 Vector<char> buffer(arr, arraysize(arr)); 2223 Vector<char> buffer(arr, arraysize(arr));
2224 const char* str; 2224 const char* str;
2225 if (number->IsSmi()) { 2225 if (number->IsSmi()) {
2226 int num = Handle<Smi>::cast(number)->value(); 2226 int num = Handle<Smi>::cast(number)->value();
2227 str = IntToCString(num, buffer); 2227 str = IntToCString(num, buffer);
2228 } else { 2228 } else {
2229 double num = Handle<HeapNumber>::cast(number)->value(); 2229 double num = Handle<HeapNumber>::cast(number)->value();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 } 2315 }
2316 *is_result_from_cache = true; 2316 *is_result_from_cache = true;
2317 if (number_of_properties == 0) { 2317 if (number_of_properties == 0) {
2318 // Reuse the initial map of the Object function if the literal has no 2318 // Reuse the initial map of the Object function if the literal has no
2319 // predeclared properties. 2319 // predeclared properties.
2320 return handle(context->object_function()->initial_map(), isolate()); 2320 return handle(context->object_function()->initial_map(), isolate());
2321 } 2321 }
2322 2322
2323 int cache_index = number_of_properties - 1; 2323 int cache_index = number_of_properties - 1;
2324 Handle<Object> maybe_cache(context->map_cache(), isolate()); 2324 Handle<Object> maybe_cache(context->map_cache(), isolate());
2325 if (maybe_cache->IsUndefined()) { 2325 if (maybe_cache->IsUndefined(isolate())) {
2326 // Allocate the new map cache for the native context. 2326 // Allocate the new map cache for the native context.
2327 maybe_cache = NewFixedArray(kMapCacheSize, TENURED); 2327 maybe_cache = NewFixedArray(kMapCacheSize, TENURED);
2328 context->set_map_cache(*maybe_cache); 2328 context->set_map_cache(*maybe_cache);
2329 } else { 2329 } else {
2330 // Check to see whether there is a matching element in the cache. 2330 // Check to see whether there is a matching element in the cache.
2331 Handle<FixedArray> cache = Handle<FixedArray>::cast(maybe_cache); 2331 Handle<FixedArray> cache = Handle<FixedArray>::cast(maybe_cache);
2332 Object* result = cache->get(cache_index); 2332 Object* result = cache->get(cache_index);
2333 if (result->IsWeakCell()) { 2333 if (result->IsWeakCell()) {
2334 WeakCell* cell = WeakCell::cast(result); 2334 WeakCell* cell = WeakCell::cast(result);
2335 if (!cell->cleared()) { 2335 if (!cell->cleared()) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 } 2390 }
2391 2391
2392 2392
2393 Handle<Object> Factory::ToBoolean(bool value) { 2393 Handle<Object> Factory::ToBoolean(bool value) {
2394 return value ? true_value() : false_value(); 2394 return value ? true_value() : false_value();
2395 } 2395 }
2396 2396
2397 2397
2398 } // namespace internal 2398 } // namespace internal
2399 } // namespace v8 2399 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698