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 9709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9720 return CompileLazyHelper(&info, flag); | 9720 return CompileLazyHelper(&info, flag); |
9721 } | 9721 } |
9722 | 9722 |
9723 | 9723 |
9724 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, | 9724 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, |
9725 ClearExceptionFlag flag) { | 9725 ClearExceptionFlag flag) { |
9726 return function->is_compiled() || CompileLazy(function, flag); | 9726 return function->is_compiled() || CompileLazy(function, flag); |
9727 } | 9727 } |
9728 | 9728 |
9729 | 9729 |
9730 bool JSFunction::IsInlineable() { | |
9731 if (IsBuiltin()) return false; | |
9732 SharedFunctionInfo* shared_info = shared(); | |
9733 // Check that the function has a script associated with it. | |
9734 if (!shared_info->script()->IsScript()) return false; | |
9735 if (shared_info->optimization_disabled()) return false; | |
9736 Code* code = shared_info->code(); | |
9737 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; | |
9738 // If we never ran this (unlikely) then lets try to optimize it. | |
9739 if (code->kind() != Code::FUNCTION) return true; | |
9740 return code->optimizable(); | |
9741 } | |
9742 | |
9743 | |
9744 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { | 9730 void JSObject::OptimizeAsPrototype(Handle<JSObject> object) { |
9745 if (object->IsGlobalObject()) return; | 9731 if (object->IsGlobalObject()) return; |
9746 | 9732 |
9747 // Make sure prototypes are fast objects and their maps have the bit set | 9733 // Make sure prototypes are fast objects and their maps have the bit set |
9748 // so they remain fast. | 9734 // so they remain fast. |
9749 if (!object->HasFastProperties()) { | 9735 if (!object->HasFastProperties()) { |
9750 TransformToFastProperties(object, 0); | 9736 TransformToFastProperties(object, 0); |
9751 } | 9737 } |
9752 } | 9738 } |
9753 | 9739 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9960 | 9946 |
9961 | 9947 |
9962 Handle<Object> SharedFunctionInfo::GetSourceCode() { | 9948 Handle<Object> SharedFunctionInfo::GetSourceCode() { |
9963 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); | 9949 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); |
9964 Handle<String> source(String::cast(Script::cast(script())->source())); | 9950 Handle<String> source(String::cast(Script::cast(script())->source())); |
9965 return GetIsolate()->factory()->NewSubString( | 9951 return GetIsolate()->factory()->NewSubString( |
9966 source, start_position(), end_position()); | 9952 source, start_position(), end_position()); |
9967 } | 9953 } |
9968 | 9954 |
9969 | 9955 |
| 9956 bool SharedFunctionInfo::IsInlineable() { |
| 9957 // Check that the function has a script associated with it. |
| 9958 if (!script()->IsScript()) return false; |
| 9959 if (optimization_disabled()) return false; |
| 9960 // If we never ran this (unlikely) then lets try to optimize it. |
| 9961 if (code()->kind() != Code::FUNCTION) return true; |
| 9962 return code()->optimizable(); |
| 9963 } |
| 9964 |
| 9965 |
9970 int SharedFunctionInfo::SourceSize() { | 9966 int SharedFunctionInfo::SourceSize() { |
9971 return end_position() - start_position(); | 9967 return end_position() - start_position(); |
9972 } | 9968 } |
9973 | 9969 |
9974 | 9970 |
9975 int SharedFunctionInfo::CalculateInstanceSize() { | 9971 int SharedFunctionInfo::CalculateInstanceSize() { |
9976 int instance_size = | 9972 int instance_size = |
9977 JSObject::kHeaderSize + | 9973 JSObject::kHeaderSize + |
9978 expected_nof_properties() * kPointerSize; | 9974 expected_nof_properties() * kPointerSize; |
9979 if (instance_size > JSObject::kMaxInstanceSize) { | 9975 if (instance_size > JSObject::kMaxInstanceSize) { |
(...skipping 6416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16396 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16392 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16397 static const char* error_messages_[] = { | 16393 static const char* error_messages_[] = { |
16398 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16394 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16399 }; | 16395 }; |
16400 #undef ERROR_MESSAGES_TEXTS | 16396 #undef ERROR_MESSAGES_TEXTS |
16401 return error_messages_[reason]; | 16397 return error_messages_[reason]; |
16402 } | 16398 } |
16403 | 16399 |
16404 | 16400 |
16405 } } // namespace v8::internal | 16401 } } // namespace v8::internal |
OLD | NEW |