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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 | 1378 |
1379 if (info->ic_age() != isolate()->heap()->global_ic_age()) { | 1379 if (info->ic_age() != isolate()->heap()->global_ic_age()) { |
1380 info->ResetForNewContext(isolate()->heap()->global_ic_age()); | 1380 info->ResetForNewContext(isolate()->heap()->global_ic_age()); |
1381 } | 1381 } |
1382 | 1382 |
1383 int index = info->SearchOptimizedCodeMap(context->native_context(), | 1383 int index = info->SearchOptimizedCodeMap(context->native_context(), |
1384 BailoutId::None()); | 1384 BailoutId::None()); |
1385 if (!info->bound() && index < 0) { | 1385 if (!info->bound() && index < 0) { |
1386 int number_of_literals = info->num_literals(); | 1386 int number_of_literals = info->num_literals(); |
1387 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); | 1387 Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure); |
1388 if (number_of_literals > 0) { | |
1389 // Store the native context in the literals array prefix. This | |
1390 // context will be used when creating object, regexp and array | |
1391 // literals in this function. | |
1392 literals->set(JSFunction::kLiteralNativeContextIndex, | |
1393 context->native_context()); | |
1394 } | |
1395 result->set_literals(*literals); | 1388 result->set_literals(*literals); |
1396 } | 1389 } |
1397 | 1390 |
1398 if (index > 0) { | 1391 if (index > 0) { |
1399 // Caching of optimized code enabled and optimized code found. | 1392 // Caching of optimized code enabled and optimized code found. |
1400 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); | 1393 FixedArray* literals = info->GetLiteralsFromOptimizedCodeMap(index); |
1401 if (literals != NULL) result->set_literals(literals); | 1394 if (literals != NULL) result->set_literals(literals); |
1402 Code* code = info->GetCodeFromOptimizedCodeMap(index); | 1395 Code* code = info->GetCodeFromOptimizedCodeMap(index); |
1403 DCHECK(!code->marked_for_deoptimization()); | 1396 DCHECK(!code->marked_for_deoptimization()); |
1404 result->ReplaceCode(code); | 1397 result->ReplaceCode(code); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2024 | 2017 |
2025 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 2018 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
2026 Handle<String> name, int number_of_literals, FunctionKind kind, | 2019 Handle<String> name, int number_of_literals, FunctionKind kind, |
2027 Handle<Code> code, Handle<ScopeInfo> scope_info, | 2020 Handle<Code> code, Handle<ScopeInfo> scope_info, |
2028 Handle<TypeFeedbackVector> feedback_vector) { | 2021 Handle<TypeFeedbackVector> feedback_vector) { |
2029 DCHECK(IsValidFunctionKind(kind)); | 2022 DCHECK(IsValidFunctionKind(kind)); |
2030 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); | 2023 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); |
2031 shared->set_scope_info(*scope_info); | 2024 shared->set_scope_info(*scope_info); |
2032 shared->set_feedback_vector(*feedback_vector); | 2025 shared->set_feedback_vector(*feedback_vector); |
2033 shared->set_kind(kind); | 2026 shared->set_kind(kind); |
2034 int literals_array_size = number_of_literals; | 2027 shared->set_num_literals(number_of_literals); |
2035 // If the function contains object, regexp or array literals, | |
2036 // allocate extra space for a literals array prefix containing the | |
2037 // context. | |
2038 if (number_of_literals > 0) { | |
2039 literals_array_size += JSFunction::kLiteralsPrefixSize; | |
2040 } | |
2041 shared->set_num_literals(literals_array_size); | |
2042 if (IsGeneratorFunction(kind)) { | 2028 if (IsGeneratorFunction(kind)) { |
2043 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 2029 shared->set_instance_class_name(isolate()->heap()->Generator_string()); |
2044 shared->DisableOptimization(kGenerator); | 2030 shared->DisableOptimization(kGenerator); |
2045 } | 2031 } |
2046 return shared; | 2032 return shared; |
2047 } | 2033 } |
2048 | 2034 |
2049 | 2035 |
2050 Handle<JSMessageObject> Factory::NewJSMessageObject( | 2036 Handle<JSMessageObject> Factory::NewJSMessageObject( |
2051 Handle<String> type, | 2037 Handle<String> type, |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 return Handle<Object>::null(); | 2318 return Handle<Object>::null(); |
2333 } | 2319 } |
2334 | 2320 |
2335 | 2321 |
2336 Handle<Object> Factory::ToBoolean(bool value) { | 2322 Handle<Object> Factory::ToBoolean(bool value) { |
2337 return value ? true_value() : false_value(); | 2323 return value ? true_value() : false_value(); |
2338 } | 2324 } |
2339 | 2325 |
2340 | 2326 |
2341 } } // namespace v8::internal | 2327 } } // namespace v8::internal |
OLD | NEW |