OLD | NEW |
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 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, | 1343 Handle<Map> initial_map, Handle<SharedFunctionInfo> info, |
1344 Handle<Context> context, PretenureFlag pretenure) { | 1344 Handle<Context> context, PretenureFlag pretenure) { |
1345 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | 1345 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); |
1346 Handle<JSFunction> result = | 1346 Handle<JSFunction> result = |
1347 NewFunction(initial_map, info, context, pretenure); | 1347 NewFunction(initial_map, info, context, pretenure); |
1348 | 1348 |
1349 if (info->ic_age() != isolate()->heap()->global_ic_age()) { | 1349 if (info->ic_age() != isolate()->heap()->global_ic_age()) { |
1350 info->ResetForNewContext(isolate()->heap()->global_ic_age()); | 1350 info->ResetForNewContext(isolate()->heap()->global_ic_age()); |
1351 } | 1351 } |
1352 | 1352 |
1353 if (FLAG_always_opt && info->allows_lazy_compilation()) { | 1353 // Give compiler a chance to pre-initialize. |
1354 result->MarkForOptimization(); | 1354 Compiler::PostInstantiation(result, pretenure); |
1355 } | |
1356 | |
1357 CodeAndLiterals cached = info->SearchOptimizedCodeMap( | |
1358 context->native_context(), BailoutId::None()); | |
1359 if (cached.code != nullptr) { | |
1360 // Caching of optimized code enabled and optimized code found. | |
1361 DCHECK(!cached.code->marked_for_deoptimization()); | |
1362 DCHECK(result->shared()->is_compiled()); | |
1363 result->ReplaceCode(cached.code); | |
1364 } | |
1365 | |
1366 if (cached.literals != nullptr) { | |
1367 result->set_literals(cached.literals); | |
1368 } else { | |
1369 int number_of_literals = info->num_literals(); | |
1370 Handle<LiteralsArray> literals = | |
1371 LiteralsArray::New(isolate(), handle(info->feedback_vector()), | |
1372 number_of_literals, pretenure); | |
1373 result->set_literals(*literals); | |
1374 | |
1375 // Cache context-specific literals. | |
1376 MaybeHandle<Code> code; | |
1377 if (cached.code != nullptr) code = handle(cached.code); | |
1378 Handle<Context> native_context(context->native_context()); | |
1379 SharedFunctionInfo::AddToOptimizedCodeMap(info, native_context, code, | |
1380 literals, BailoutId::None()); | |
1381 } | |
1382 | 1355 |
1383 return result; | 1356 return result; |
1384 } | 1357 } |
1385 | 1358 |
1386 | 1359 |
1387 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { | 1360 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { |
1388 Handle<FixedArray> array = NewFixedArray(length, TENURED); | 1361 Handle<FixedArray> array = NewFixedArray(length, TENURED); |
1389 array->set_map_no_write_barrier(*scope_info_map()); | 1362 array->set_map_no_write_barrier(*scope_info_map()); |
1390 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); | 1363 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); |
1391 return scope_info; | 1364 return scope_info; |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 } | 2358 } |
2386 | 2359 |
2387 | 2360 |
2388 Handle<Object> Factory::ToBoolean(bool value) { | 2361 Handle<Object> Factory::ToBoolean(bool value) { |
2389 return value ? true_value() : false_value(); | 2362 return value ? true_value() : false_value(); |
2390 } | 2363 } |
2391 | 2364 |
2392 | 2365 |
2393 } // namespace internal | 2366 } // namespace internal |
2394 } // namespace v8 | 2367 } // namespace v8 |
OLD | NEW |