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/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); | 1351 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); |
1352 | 1352 |
1353 if (!function->shared()->is_generator()) { | 1353 if (!function->shared()->is_generator()) { |
1354 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM); | 1354 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM); |
1355 } | 1355 } |
1356 | 1356 |
1357 return prototype; | 1357 return prototype; |
1358 } | 1358 } |
1359 | 1359 |
1360 | 1360 |
| 1361 static bool ShouldOptimizeNewClosure(Isolate* isolate, |
| 1362 Handle<SharedFunctionInfo> info) { |
| 1363 return isolate->use_crankshaft() && !info->is_toplevel() && |
| 1364 info->is_compiled() && info->allows_lazy_compilation() && |
| 1365 !info->optimization_disabled() && !isolate->DebuggerHasBreakPoints(); |
| 1366 } |
| 1367 |
| 1368 |
1361 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( | 1369 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
1362 Handle<SharedFunctionInfo> info, | 1370 Handle<SharedFunctionInfo> info, |
1363 Handle<Context> context, | 1371 Handle<Context> context, |
1364 PretenureFlag pretenure) { | 1372 PretenureFlag pretenure) { |
1365 int map_index = Context::FunctionMapIndex(info->strict_mode(), info->kind()); | 1373 int map_index = Context::FunctionMapIndex(info->strict_mode(), info->kind()); |
1366 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); | 1374 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); |
1367 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); | 1375 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); |
1368 | 1376 |
1369 if (info->ic_age() != isolate()->heap()->global_ic_age()) { | 1377 if (info->ic_age() != isolate()->heap()->global_ic_age()) { |
1370 info->ResetForNewContext(isolate()->heap()->global_ic_age()); | 1378 info->ResetForNewContext(isolate()->heap()->global_ic_age()); |
(...skipping 17 matching lines...) Expand all Loading... |
1388 if (index > 0) { | 1396 if (index > 0) { |
1389 // Caching of optimized code enabled and optimized code found. | 1397 // Caching of optimized code enabled and optimized code found. |
1390 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); | 1398 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); |
1391 if (literals != NULL) result->set_literals(literals); | 1399 if (literals != NULL) result->set_literals(literals); |
1392 Code* code = info->GetCodeFromOptimizedCodeMap(index); | 1400 Code* code = info->GetCodeFromOptimizedCodeMap(index); |
1393 DCHECK(!code->marked_for_deoptimization()); | 1401 DCHECK(!code->marked_for_deoptimization()); |
1394 result->ReplaceCode(code); | 1402 result->ReplaceCode(code); |
1395 return result; | 1403 return result; |
1396 } | 1404 } |
1397 | 1405 |
1398 if (isolate()->use_crankshaft() && | 1406 if (FLAG_always_opt && ShouldOptimizeNewClosure(isolate(), info)) { |
1399 FLAG_always_opt && | |
1400 result->is_compiled() && | |
1401 !info->is_toplevel() && | |
1402 info->allows_lazy_compilation() && | |
1403 !info->optimization_disabled() && | |
1404 !isolate()->DebuggerHasBreakPoints()) { | |
1405 result->MarkForOptimization(); | 1407 result->MarkForOptimization(); |
| 1408 } else if (info->optimize_next_closure() && |
| 1409 ShouldOptimizeNewClosure(isolate(), info)) { |
| 1410 result->AttemptConcurrentOptimization(); |
1406 } | 1411 } |
1407 return result; | 1412 return result; |
1408 } | 1413 } |
1409 | 1414 |
1410 | 1415 |
1411 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { | 1416 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { |
1412 Handle<FixedArray> array = NewFixedArray(length, TENURED); | 1417 Handle<FixedArray> array = NewFixedArray(length, TENURED); |
1413 array->set_map_no_write_barrier(*scope_info_map()); | 1418 array->set_map_no_write_barrier(*scope_info_map()); |
1414 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); | 1419 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); |
1415 return scope_info; | 1420 return scope_info; |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2498 return Handle<Object>::null(); | 2503 return Handle<Object>::null(); |
2499 } | 2504 } |
2500 | 2505 |
2501 | 2506 |
2502 Handle<Object> Factory::ToBoolean(bool value) { | 2507 Handle<Object> Factory::ToBoolean(bool value) { |
2503 return value ? true_value() : false_value(); | 2508 return value ? true_value() : false_value(); |
2504 } | 2509 } |
2505 | 2510 |
2506 | 2511 |
2507 } } // namespace v8::internal | 2512 } } // namespace v8::internal |
OLD | NEW |