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 9724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9735 return CompileLazyHelper(&info, flag); | 9735 return CompileLazyHelper(&info, flag); |
9736 } | 9736 } |
9737 | 9737 |
9738 | 9738 |
9739 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, | 9739 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, |
9740 ClearExceptionFlag flag) { | 9740 ClearExceptionFlag flag) { |
9741 return function->is_compiled() || CompileLazy(function, flag); | 9741 return function->is_compiled() || CompileLazy(function, flag); |
9742 } | 9742 } |
9743 | 9743 |
9744 | 9744 |
9745 bool JSFunction::IsInlineable() { | |
9746 if (IsBuiltin()) return false; | |
9747 SharedFunctionInfo* shared_info = shared(); | |
9748 // Check that the function has a script associated with it. | |
9749 if (!shared_info->script()->IsScript()) return false; | |
9750 if (shared_info->optimization_disabled()) return false; | |
9751 Code* code = shared_info->code(); | |
9752 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; | |
9753 // If we never ran this (unlikely) then lets try to optimize it. | |
9754 if (code->kind() != Code::FUNCTION) return true; | |
9755 return code->optimizable(); | |
9756 } | |
9757 | |
9758 | |
9759 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { | 9745 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { |
9760 if (object->IsGlobalObject()) return; | 9746 if (object->IsGlobalObject()) return; |
9761 | 9747 |
9762 // Make sure prototypes are fast objects and their maps have the bit set | 9748 // Make sure prototypes are fast objects and their maps have the bit set |
9763 // so they remain fast. | 9749 // so they remain fast. |
9764 if (!object->HasFastProperties()) { | 9750 if (!object->HasFastProperties()) { |
9765 TransformToFastProperties(object, 0); | 9751 TransformToFastProperties(object, 0); |
9766 } | 9752 } |
9767 } | 9753 } |
9768 | 9754 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10017 | 10003 |
10018 | 10004 |
10019 Handle<Object> SharedFunctionInfo::GetSourceCode() { | 10005 Handle<Object> SharedFunctionInfo::GetSourceCode() { |
10020 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); | 10006 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); |
10021 Handle<String> source(String::cast(Script::cast(script())->source())); | 10007 Handle<String> source(String::cast(Script::cast(script())->source())); |
10022 return GetIsolate()->factory()->NewSubString( | 10008 return GetIsolate()->factory()->NewSubString( |
10023 source, start_position(), end_position()); | 10009 source, start_position(), end_position()); |
10024 } | 10010 } |
10025 | 10011 |
10026 | 10012 |
| 10013 bool SharedFunctionInfo::IsInlineable() { |
| 10014 // Check that the function has a script associated with it. |
| 10015 if (!script()->IsScript()) return false; |
| 10016 if (optimization_disabled()) return false; |
| 10017 // If we never ran this (unlikely) then lets try to optimize it. |
| 10018 if (code()->kind() != Code::FUNCTION) return true; |
| 10019 return code()->optimizable(); |
| 10020 } |
| 10021 |
| 10022 |
10027 int SharedFunctionInfo::SourceSize() { | 10023 int SharedFunctionInfo::SourceSize() { |
10028 return end_position() - start_position(); | 10024 return end_position() - start_position(); |
10029 } | 10025 } |
10030 | 10026 |
10031 | 10027 |
10032 int SharedFunctionInfo::CalculateInstanceSize() { | 10028 int SharedFunctionInfo::CalculateInstanceSize() { |
10033 int instance_size = | 10029 int instance_size = |
10034 JSObject::kHeaderSize + | 10030 JSObject::kHeaderSize + |
10035 expected_nof_properties() * kPointerSize; | 10031 expected_nof_properties() * kPointerSize; |
10036 if (instance_size > JSObject::kMaxInstanceSize) { | 10032 if (instance_size > JSObject::kMaxInstanceSize) { |
(...skipping 6493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16530 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16526 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16531 static const char* error_messages_[] = { | 16527 static const char* error_messages_[] = { |
16532 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16528 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16533 }; | 16529 }; |
16534 #undef ERROR_MESSAGES_TEXTS | 16530 #undef ERROR_MESSAGES_TEXTS |
16535 return error_messages_[reason]; | 16531 return error_messages_[reason]; |
16536 } | 16532 } |
16537 | 16533 |
16538 | 16534 |
16539 } } // namespace v8::internal | 16535 } } // namespace v8::internal |
OLD | NEW |