| 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 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); | 1359 Handle<JSObject> prototype = NewJSObjectFromMap(new_map); |
| 1360 | 1360 |
| 1361 if (!function->shared()->is_generator()) { | 1361 if (!function->shared()->is_generator()) { |
| 1362 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM); | 1362 JSObject::AddProperty(prototype, constructor_string(), function, DONT_ENUM); |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 return prototype; | 1365 return prototype; |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 | 1368 |
| 1369 static bool ShouldOptimizeNewClosure(Handle<SharedFunctionInfo> info) { | |
| 1370 return !info->is_toplevel() && info->allows_lazy_compilation(); | |
| 1371 } | |
| 1372 | |
| 1373 | |
| 1374 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( | 1369 Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( |
| 1375 Handle<SharedFunctionInfo> info, | 1370 Handle<SharedFunctionInfo> info, |
| 1376 Handle<Context> context, | 1371 Handle<Context> context, |
| 1377 PretenureFlag pretenure) { | 1372 PretenureFlag pretenure) { |
| 1378 int map_index = | 1373 int map_index = |
| 1379 Context::FunctionMapIndex(info->language_mode(), info->kind()); | 1374 Context::FunctionMapIndex(info->language_mode(), info->kind()); |
| 1380 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); | 1375 Handle<Map> map(Map::cast(context->native_context()->get(map_index))); |
| 1381 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); | 1376 Handle<JSFunction> result = NewFunction(map, info, context, pretenure); |
| 1382 | 1377 |
| 1383 if (info->ic_age() != isolate()->heap()->global_ic_age()) { | 1378 if (info->ic_age() != isolate()->heap()->global_ic_age()) { |
| 1384 info->ResetForNewContext(isolate()->heap()->global_ic_age()); | 1379 info->ResetForNewContext(isolate()->heap()->global_ic_age()); |
| 1385 } | 1380 } |
| 1386 | 1381 |
| 1382 if (FLAG_always_opt && info->allows_lazy_compilation()) { |
| 1383 result->MarkForOptimization(); |
| 1384 } |
| 1385 |
| 1387 int index = info->SearchOptimizedCodeMap(context->native_context(), | 1386 int index = info->SearchOptimizedCodeMap(context->native_context(), |
| 1388 BailoutId::None()); | 1387 BailoutId::None()); |
| 1389 if (!info->bound() && index < 0) { | 1388 if (!info->bound() && index < 0) { |
| 1390 int number_of_literals = info->num_literals(); | 1389 int number_of_literals = info->num_literals(); |
| 1391 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); | 1390 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); |
| 1392 result->set_literals(*literals); | 1391 result->set_literals(*literals); |
| 1393 } | 1392 } |
| 1394 | 1393 |
| 1395 if (index > 0) { | 1394 if (index > 0) { |
| 1396 // Caching of optimized code enabled and optimized code found. | 1395 // Caching of optimized code enabled and optimized code found. |
| 1397 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); | 1396 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); |
| 1398 if (literals != NULL) result->set_literals(literals); | 1397 if (literals != NULL) result->set_literals(literals); |
| 1399 Code* code = info->GetCodeFromOptimizedCodeMap(index); | 1398 Code* code = info->GetCodeFromOptimizedCodeMap(index); |
| 1400 DCHECK(!code->marked_for_deoptimization()); | 1399 DCHECK(!code->marked_for_deoptimization()); |
| 1401 result->ReplaceCode(code); | 1400 result->ReplaceCode(code); |
| 1402 return result; | |
| 1403 } | 1401 } |
| 1404 | 1402 |
| 1405 if (FLAG_always_opt && ShouldOptimizeNewClosure(info)) { | |
| 1406 result->MarkForOptimization(); | |
| 1407 } | |
| 1408 return result; | 1403 return result; |
| 1409 } | 1404 } |
| 1410 | 1405 |
| 1411 | 1406 |
| 1412 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { | 1407 Handle<ScopeInfo> Factory::NewScopeInfo(int length) { |
| 1413 Handle<FixedArray> array = NewFixedArray(length, TENURED); | 1408 Handle<FixedArray> array = NewFixedArray(length, TENURED); |
| 1414 array->set_map_no_write_barrier(*scope_info_map()); | 1409 array->set_map_no_write_barrier(*scope_info_map()); |
| 1415 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); | 1410 Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::cast(array); |
| 1416 return scope_info; | 1411 return scope_info; |
| 1417 } | 1412 } |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 return Handle<Object>::null(); | 2329 return Handle<Object>::null(); |
| 2335 } | 2330 } |
| 2336 | 2331 |
| 2337 | 2332 |
| 2338 Handle<Object> Factory::ToBoolean(bool value) { | 2333 Handle<Object> Factory::ToBoolean(bool value) { |
| 2339 return value ? true_value() : false_value(); | 2334 return value ? true_value() : false_value(); |
| 2340 } | 2335 } |
| 2341 | 2336 |
| 2342 | 2337 |
| 2343 } } // namespace v8::internal | 2338 } } // namespace v8::internal |
| OLD | NEW |