OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 9729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9740 return CompileLazyHelper(&info, flag); | 9740 return CompileLazyHelper(&info, flag); |
9741 } | 9741 } |
9742 | 9742 |
9743 | 9743 |
9744 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, | 9744 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, |
9745 ClearExceptionFlag flag) { | 9745 ClearExceptionFlag flag) { |
9746 return function->is_compiled() || CompileLazy(function, flag); | 9746 return function->is_compiled() || CompileLazy(function, flag); |
9747 } | 9747 } |
9748 | 9748 |
9749 | 9749 |
| 9750 bool JSFunction::IsInlineable() { |
| 9751 if (IsBuiltin()) return false; |
| 9752 SharedFunctionInfo* shared_info = shared(); |
| 9753 // Check that the function has a script associated with it. |
| 9754 if (!shared_info->script()->IsScript()) return false; |
| 9755 if (shared_info->optimization_disabled()) return false; |
| 9756 Code* code = shared_info->code(); |
| 9757 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; |
| 9758 // If we never ran this (unlikely) then lets try to optimize it. |
| 9759 if (code->kind() != Code::FUNCTION) return true; |
| 9760 return code->optimizable(); |
| 9761 } |
| 9762 |
| 9763 |
9750 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { | 9764 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { |
9751 if (object->IsGlobalObject()) return; | 9765 if (object->IsGlobalObject()) return; |
9752 | 9766 |
9753 // Make sure prototypes are fast objects and their maps have the bit set | 9767 // Make sure prototypes are fast objects and their maps have the bit set |
9754 // so they remain fast. | 9768 // so they remain fast. |
9755 if (!object->HasFastProperties()) { | 9769 if (!object->HasFastProperties()) { |
9756 TransformToFastProperties(object, 0); | 9770 TransformToFastProperties(object, 0); |
9757 } | 9771 } |
9758 } | 9772 } |
9759 | 9773 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10008 | 10022 |
10009 | 10023 |
10010 Handle<Object> SharedFunctionInfo::GetSourceCode() { | 10024 Handle<Object> SharedFunctionInfo::GetSourceCode() { |
10011 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); | 10025 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); |
10012 Handle<String> source(String::cast(Script::cast(script())->source())); | 10026 Handle<String> source(String::cast(Script::cast(script())->source())); |
10013 return GetIsolate()->factory()->NewSubString( | 10027 return GetIsolate()->factory()->NewSubString( |
10014 source, start_position(), end_position()); | 10028 source, start_position(), end_position()); |
10015 } | 10029 } |
10016 | 10030 |
10017 | 10031 |
10018 bool SharedFunctionInfo::IsInlineable() { | |
10019 // Check that the function has a script associated with it. | |
10020 if (!script()->IsScript()) return false; | |
10021 if (optimization_disabled()) return false; | |
10022 // If we never ran this (unlikely) then lets try to optimize it. | |
10023 if (code()->kind() != Code::FUNCTION) return true; | |
10024 return code()->optimizable(); | |
10025 } | |
10026 | |
10027 | |
10028 int SharedFunctionInfo::SourceSize() { | 10032 int SharedFunctionInfo::SourceSize() { |
10029 return end_position() - start_position(); | 10033 return end_position() - start_position(); |
10030 } | 10034 } |
10031 | 10035 |
10032 | 10036 |
10033 int SharedFunctionInfo::CalculateInstanceSize() { | 10037 int SharedFunctionInfo::CalculateInstanceSize() { |
10034 int instance_size = | 10038 int instance_size = |
10035 JSObject::kHeaderSize + | 10039 JSObject::kHeaderSize + |
10036 expected_nof_properties() * kPointerSize; | 10040 expected_nof_properties() * kPointerSize; |
10037 if (instance_size > JSObject::kMaxInstanceSize) { | 10041 if (instance_size > JSObject::kMaxInstanceSize) { |
(...skipping 6493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16531 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16535 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16532 static const char* error_messages_[] = { | 16536 static const char* error_messages_[] = { |
16533 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16537 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16534 }; | 16538 }; |
16535 #undef ERROR_MESSAGES_TEXTS | 16539 #undef ERROR_MESSAGES_TEXTS |
16536 return error_messages_[reason]; | 16540 return error_messages_[reason]; |
16537 } | 16541 } |
16538 | 16542 |
16539 | 16543 |
16540 } } // namespace v8::internal | 16544 } } // namespace v8::internal |
OLD | NEW |