OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
11 | 11 |
12 #ifndef V8_OBJECTS_INL_H_ | 12 #ifndef V8_OBJECTS_INL_H_ |
13 #define V8_OBJECTS_INL_H_ | 13 #define V8_OBJECTS_INL_H_ |
14 | 14 |
15 #include "src/base/atomicops.h" | 15 #include "src/base/atomicops.h" |
16 #include "src/base/bits.h" | 16 #include "src/base/bits.h" |
| 17 #include "src/builtins.h" |
17 #include "src/contexts-inl.h" | 18 #include "src/contexts-inl.h" |
18 #include "src/conversions-inl.h" | 19 #include "src/conversions-inl.h" |
19 #include "src/factory.h" | 20 #include "src/factory.h" |
20 #include "src/field-index-inl.h" | 21 #include "src/field-index-inl.h" |
21 #include "src/field-type.h" | 22 #include "src/field-type.h" |
22 #include "src/handles-inl.h" | 23 #include "src/handles-inl.h" |
23 #include "src/heap/heap-inl.h" | 24 #include "src/heap/heap-inl.h" |
24 #include "src/heap/heap.h" | 25 #include "src/heap/heap.h" |
25 #include "src/isolate-inl.h" | 26 #include "src/isolate-inl.h" |
26 #include "src/isolate.h" | 27 #include "src/isolate.h" |
(...skipping 4824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4851 } | 4852 } |
4852 | 4853 |
4853 | 4854 |
4854 bool Code::IsCodeStubOrIC() { | 4855 bool Code::IsCodeStubOrIC() { |
4855 return kind() == STUB || kind() == HANDLER || kind() == LOAD_IC || | 4856 return kind() == STUB || kind() == HANDLER || kind() == LOAD_IC || |
4856 kind() == KEYED_LOAD_IC || kind() == CALL_IC || kind() == STORE_IC || | 4857 kind() == KEYED_LOAD_IC || kind() == CALL_IC || kind() == STORE_IC || |
4857 kind() == KEYED_STORE_IC || kind() == BINARY_OP_IC || | 4858 kind() == KEYED_STORE_IC || kind() == BINARY_OP_IC || |
4858 kind() == COMPARE_IC || kind() == TO_BOOLEAN_IC; | 4859 kind() == COMPARE_IC || kind() == TO_BOOLEAN_IC; |
4859 } | 4860 } |
4860 | 4861 |
4861 InlineCacheState Code::ic_state() { | |
4862 InlineCacheState result = ExtractICStateFromFlags(flags()); | |
4863 // Only allow uninitialized or debugger states for non-IC code | |
4864 // objects. This is used in the debugger to determine whether or not | |
4865 // a call to code object has been replaced with a debug break call. | |
4866 DCHECK(is_inline_cache_stub() || | |
4867 result == UNINITIALIZED || | |
4868 result == DEBUG_STUB); | |
4869 return result; | |
4870 } | |
4871 | |
4872 | 4862 |
4873 ExtraICState Code::extra_ic_state() { | 4863 ExtraICState Code::extra_ic_state() { |
4874 DCHECK(is_inline_cache_stub() || ic_state() == DEBUG_STUB); | 4864 DCHECK(is_inline_cache_stub() || is_debug_stub()); |
4875 return ExtractExtraICStateFromFlags(flags()); | 4865 return ExtractExtraICStateFromFlags(flags()); |
4876 } | 4866 } |
4877 | 4867 |
4878 | 4868 |
4879 // For initialization. | 4869 // For initialization. |
4880 void Code::set_raw_kind_specific_flags1(int value) { | 4870 void Code::set_raw_kind_specific_flags1(int value) { |
4881 WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value); | 4871 WRITE_INT_FIELD(this, kKindSpecificFlags1Offset, value); |
4882 } | 4872 } |
4883 | 4873 |
4884 | 4874 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5100 bool Code::is_inline_cache_stub() { | 5090 bool Code::is_inline_cache_stub() { |
5101 Kind kind = this->kind(); | 5091 Kind kind = this->kind(); |
5102 switch (kind) { | 5092 switch (kind) { |
5103 #define CASE(name) case name: return true; | 5093 #define CASE(name) case name: return true; |
5104 IC_KIND_LIST(CASE) | 5094 IC_KIND_LIST(CASE) |
5105 #undef CASE | 5095 #undef CASE |
5106 default: return false; | 5096 default: return false; |
5107 } | 5097 } |
5108 } | 5098 } |
5109 | 5099 |
5110 bool Code::is_debug_stub() { return ic_state() == DEBUG_STUB; } | 5100 bool Code::is_debug_stub() { |
| 5101 if (kind() != BUILTIN) return false; |
| 5102 switch (builtin_index()) { |
| 5103 #define CASE_DEBUG_BUILTIN(name, kind, extra) case Builtins::k##name: |
| 5104 BUILTIN_LIST_DEBUG_A(CASE_DEBUG_BUILTIN) |
| 5105 #undef CASE_DEBUG_BUILTIN |
| 5106 return true; |
| 5107 default: |
| 5108 return false; |
| 5109 } |
| 5110 return false; |
| 5111 } |
5111 bool Code::is_handler() { return kind() == HANDLER; } | 5112 bool Code::is_handler() { return kind() == HANDLER; } |
5112 bool Code::is_call_stub() { return kind() == CALL_IC; } | 5113 bool Code::is_call_stub() { return kind() == CALL_IC; } |
5113 bool Code::is_binary_op_stub() { return kind() == BINARY_OP_IC; } | 5114 bool Code::is_binary_op_stub() { return kind() == BINARY_OP_IC; } |
5114 bool Code::is_compare_ic_stub() { return kind() == COMPARE_IC; } | 5115 bool Code::is_compare_ic_stub() { return kind() == COMPARE_IC; } |
5115 bool Code::is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } | 5116 bool Code::is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } |
5116 bool Code::is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; } | 5117 bool Code::is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; } |
5117 bool Code::is_wasm_code() { return kind() == WASM_FUNCTION; } | 5118 bool Code::is_wasm_code() { return kind() == WASM_FUNCTION; } |
5118 | 5119 |
5119 bool Code::embeds_maps_weakly() { | |
5120 Kind k = kind(); | |
5121 return (k == LOAD_IC || k == STORE_IC || k == KEYED_LOAD_IC || | |
5122 k == KEYED_STORE_IC) && | |
5123 ic_state() == MONOMORPHIC; | |
5124 } | |
5125 | |
5126 | |
5127 Address Code::constant_pool() { | 5120 Address Code::constant_pool() { |
5128 Address constant_pool = NULL; | 5121 Address constant_pool = NULL; |
5129 if (FLAG_enable_embedded_constant_pool) { | 5122 if (FLAG_enable_embedded_constant_pool) { |
5130 int offset = constant_pool_offset(); | 5123 int offset = constant_pool_offset(); |
5131 if (offset < instruction_size()) { | 5124 if (offset < instruction_size()) { |
5132 constant_pool = FIELD_ADDR(this, kHeaderSize + offset); | 5125 constant_pool = FIELD_ADDR(this, kHeaderSize + offset); |
5133 } | 5126 } |
5134 } | 5127 } |
5135 return constant_pool; | 5128 return constant_pool; |
5136 } | 5129 } |
5137 | 5130 |
5138 Code::Flags Code::ComputeFlags(Kind kind, InlineCacheState ic_state, | 5131 Code::Flags Code::ComputeFlags(Kind kind, ExtraICState extra_ic_state, |
5139 ExtraICState extra_ic_state, | |
5140 CacheHolderFlag holder) { | 5132 CacheHolderFlag holder) { |
5141 // Compute the bit mask. | 5133 // Compute the bit mask. |
5142 unsigned int bits = KindField::encode(kind) | ICStateField::encode(ic_state) | | 5134 unsigned int bits = KindField::encode(kind) | |
5143 ExtraICStateField::encode(extra_ic_state) | | 5135 ExtraICStateField::encode(extra_ic_state) | |
5144 CacheHolderField::encode(holder); | 5136 CacheHolderField::encode(holder); |
5145 return static_cast<Flags>(bits); | 5137 return static_cast<Flags>(bits); |
5146 } | 5138 } |
5147 | 5139 |
5148 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, | |
5149 ExtraICState extra_ic_state, | |
5150 CacheHolderFlag holder) { | |
5151 return ComputeFlags(kind, MONOMORPHIC, extra_ic_state, holder); | |
5152 } | |
5153 | |
5154 Code::Flags Code::ComputeHandlerFlags(Kind handler_kind, | 5140 Code::Flags Code::ComputeHandlerFlags(Kind handler_kind, |
5155 CacheHolderFlag holder) { | 5141 CacheHolderFlag holder) { |
5156 return ComputeFlags(Code::HANDLER, MONOMORPHIC, handler_kind, holder); | 5142 return ComputeFlags(Code::HANDLER, handler_kind, holder); |
5157 } | 5143 } |
5158 | 5144 |
5159 | 5145 |
5160 Code::Kind Code::ExtractKindFromFlags(Flags flags) { | 5146 Code::Kind Code::ExtractKindFromFlags(Flags flags) { |
5161 return KindField::decode(flags); | 5147 return KindField::decode(flags); |
5162 } | 5148 } |
5163 | 5149 |
5164 | 5150 |
5165 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { | |
5166 return ICStateField::decode(flags); | |
5167 } | |
5168 | |
5169 | |
5170 ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { | 5151 ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { |
5171 return ExtraICStateField::decode(flags); | 5152 return ExtraICStateField::decode(flags); |
5172 } | 5153 } |
5173 | 5154 |
5174 | 5155 |
5175 CacheHolderFlag Code::ExtractCacheHolderFromFlags(Flags flags) { | 5156 CacheHolderFlag Code::ExtractCacheHolderFromFlags(Flags flags) { |
5176 return CacheHolderField::decode(flags); | 5157 return CacheHolderField::decode(flags); |
5177 } | 5158 } |
5178 | 5159 |
5179 Code::Flags Code::RemoveHolderFromFlags(Flags flags) { | 5160 Code::Flags Code::RemoveHolderFromFlags(Flags flags) { |
(...skipping 2752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7932 #undef WRITE_INT64_FIELD | 7913 #undef WRITE_INT64_FIELD |
7933 #undef READ_BYTE_FIELD | 7914 #undef READ_BYTE_FIELD |
7934 #undef WRITE_BYTE_FIELD | 7915 #undef WRITE_BYTE_FIELD |
7935 #undef NOBARRIER_READ_BYTE_FIELD | 7916 #undef NOBARRIER_READ_BYTE_FIELD |
7936 #undef NOBARRIER_WRITE_BYTE_FIELD | 7917 #undef NOBARRIER_WRITE_BYTE_FIELD |
7937 | 7918 |
7938 } // namespace internal | 7919 } // namespace internal |
7939 } // namespace v8 | 7920 } // namespace v8 |
7940 | 7921 |
7941 #endif // V8_OBJECTS_INL_H_ | 7922 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |