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 // |
(...skipping 3361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3372 } | 3372 } |
3373 | 3373 |
3374 | 3374 |
3375 LiteralsArray* LiteralsArray::cast(Object* object) { | 3375 LiteralsArray* LiteralsArray::cast(Object* object) { |
3376 SLOW_DCHECK(object->IsLiteralsArray()); | 3376 SLOW_DCHECK(object->IsLiteralsArray()); |
3377 return reinterpret_cast<LiteralsArray*>(object); | 3377 return reinterpret_cast<LiteralsArray*>(object); |
3378 } | 3378 } |
3379 | 3379 |
3380 | 3380 |
3381 TypeFeedbackVector* LiteralsArray::feedback_vector() const { | 3381 TypeFeedbackVector* LiteralsArray::feedback_vector() const { |
| 3382 if (length() == 0) { |
| 3383 return TypeFeedbackVector::cast( |
| 3384 const_cast<FixedArray*>(FixedArray::cast(this))); |
| 3385 } |
3382 return TypeFeedbackVector::cast(get(kVectorIndex)); | 3386 return TypeFeedbackVector::cast(get(kVectorIndex)); |
3383 } | 3387 } |
3384 | 3388 |
3385 | 3389 |
3386 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { | 3390 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { |
| 3391 if (length() <= kVectorIndex) { |
| 3392 DCHECK(vector->length() == 0); |
| 3393 return; |
| 3394 } |
3387 set(kVectorIndex, vector); | 3395 set(kVectorIndex, vector); |
3388 } | 3396 } |
3389 | 3397 |
3390 | 3398 |
3391 Object* LiteralsArray::literal(int literal_index) const { | 3399 Object* LiteralsArray::literal(int literal_index) const { |
3392 return get(kFirstLiteralIndex + literal_index); | 3400 return get(kFirstLiteralIndex + literal_index); |
3393 } | 3401 } |
3394 | 3402 |
3395 | 3403 |
3396 void LiteralsArray::set_literal(int literal_index, Object* literal) { | 3404 void LiteralsArray::set_literal(int literal_index, Object* literal) { |
3397 set(kFirstLiteralIndex + literal_index, literal); | 3405 set(kFirstLiteralIndex + literal_index, literal); |
3398 } | 3406 } |
3399 | 3407 |
| 3408 void LiteralsArray::set_literal_undefined(int literal_index) { |
| 3409 set_undefined(kFirstLiteralIndex + literal_index); |
| 3410 } |
3400 | 3411 |
3401 int LiteralsArray::literals_count() const { | 3412 int LiteralsArray::literals_count() const { |
3402 return length() - kFirstLiteralIndex; | 3413 return length() - kFirstLiteralIndex; |
3403 } | 3414 } |
3404 | 3415 |
3405 int HandlerTable::GetRangeStart(int index) const { | 3416 int HandlerTable::GetRangeStart(int index) const { |
3406 return Smi::cast(get(index * kRangeEntrySize + kRangeStartIndex))->value(); | 3417 return Smi::cast(get(index * kRangeEntrySize + kRangeStartIndex))->value(); |
3407 } | 3418 } |
3408 | 3419 |
3409 int HandlerTable::GetRangeEnd(int index) const { | 3420 int HandlerTable::GetRangeEnd(int index) const { |
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5628 | 5639 |
5629 SMI_ACCESSORS(BreakPointInfo, code_offset, kCodeOffsetIndex) | 5640 SMI_ACCESSORS(BreakPointInfo, code_offset, kCodeOffsetIndex) |
5630 SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionIndex) | 5641 SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionIndex) |
5631 SMI_ACCESSORS(BreakPointInfo, statement_position, kStatementPositionIndex) | 5642 SMI_ACCESSORS(BreakPointInfo, statement_position, kStatementPositionIndex) |
5632 ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex) | 5643 ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex) |
5633 | 5644 |
5634 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) | 5645 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) |
5635 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, | 5646 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, |
5636 kOptimizedCodeMapOffset) | 5647 kOptimizedCodeMapOffset) |
5637 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) | 5648 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) |
5638 ACCESSORS(SharedFunctionInfo, feedback_vector, TypeFeedbackVector, | 5649 ACCESSORS(SharedFunctionInfo, feedback_metadata, TypeFeedbackMetadata, |
5639 kFeedbackVectorOffset) | 5650 kFeedbackMetadataOffset) |
5640 #if TRACE_MAPS | 5651 #if TRACE_MAPS |
5641 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset) | 5652 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset) |
5642 #endif | 5653 #endif |
5643 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, | 5654 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, |
5644 kInstanceClassNameOffset) | 5655 kInstanceClassNameOffset) |
5645 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) | 5656 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) |
5646 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) | 5657 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) |
5647 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) | 5658 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) |
5648 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) | 5659 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) |
5649 | 5660 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5811 } | 5822 } |
5812 | 5823 |
5813 | 5824 |
5814 void SharedFunctionInfo::set_kind(FunctionKind kind) { | 5825 void SharedFunctionInfo::set_kind(FunctionKind kind) { |
5815 DCHECK(IsValidFunctionKind(kind)); | 5826 DCHECK(IsValidFunctionKind(kind)); |
5816 int hints = compiler_hints(); | 5827 int hints = compiler_hints(); |
5817 hints = FunctionKindBits::update(hints, kind); | 5828 hints = FunctionKindBits::update(hints, kind); |
5818 set_compiler_hints(hints); | 5829 set_compiler_hints(hints); |
5819 } | 5830 } |
5820 | 5831 |
| 5832 // static |
| 5833 int SharedFunctionInfo::OffsetToPreviousContext() { |
| 5834 return FixedArray::kHeaderSize + |
| 5835 kPointerSize * (kContextOffset - kEntryLength); |
| 5836 } |
| 5837 |
| 5838 int SharedFunctionInfo::OffsetToPreviousCachedCode() { |
| 5839 return FixedArray::kHeaderSize + |
| 5840 kPointerSize * (kCachedCodeOffset - kEntryLength); |
| 5841 } |
| 5842 |
| 5843 int SharedFunctionInfo::OffsetToPreviousLiterals() { |
| 5844 return FixedArray::kHeaderSize + |
| 5845 kPointerSize * (kLiteralsOffset - kEntryLength); |
| 5846 } |
| 5847 |
| 5848 int SharedFunctionInfo::OffsetToPreviousOsrAstId() { |
| 5849 return FixedArray::kHeaderSize + |
| 5850 kPointerSize * (kOsrAstIdOffset - kEntryLength); |
| 5851 } |
5821 | 5852 |
5822 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object, | 5853 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object, |
5823 kNeedsHomeObject) | 5854 kNeedsHomeObject) |
5824 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) | 5855 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) |
5825 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline) | 5856 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline) |
5826 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, | 5857 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, |
5827 name_should_print_as_anonymous, | 5858 name_should_print_as_anonymous, |
5828 kNameShouldPrintAsAnonymous) | 5859 kNameShouldPrintAsAnonymous) |
5829 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) | 5860 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) |
5830 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction) | 5861 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction) |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6262 } | 6293 } |
6263 | 6294 |
6264 | 6295 |
6265 bool JSFunction::is_compiled() { | 6296 bool JSFunction::is_compiled() { |
6266 Builtins* builtins = GetIsolate()->builtins(); | 6297 Builtins* builtins = GetIsolate()->builtins(); |
6267 return code() != builtins->builtin(Builtins::kCompileLazy) && | 6298 return code() != builtins->builtin(Builtins::kCompileLazy) && |
6268 code() != builtins->builtin(Builtins::kCompileOptimized) && | 6299 code() != builtins->builtin(Builtins::kCompileOptimized) && |
6269 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent); | 6300 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent); |
6270 } | 6301 } |
6271 | 6302 |
6272 | 6303 TypeFeedbackVector* JSFunction::feedback_vector() { |
6273 int JSFunction::NumberOfLiterals() { | 6304 LiteralsArray* array = literals(); |
6274 return literals()->length(); | 6305 return array->feedback_vector(); |
6275 } | 6306 } |
6276 | 6307 |
| 6308 int JSFunction::NumberOfLiterals() { return literals()->literals_count(); } |
6277 | 6309 |
6278 ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset) | 6310 ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset) |
6279 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) | 6311 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) |
6280 ACCESSORS(JSProxy, hash, Object, kHashOffset) | 6312 ACCESSORS(JSProxy, hash, Object, kHashOffset) |
6281 | 6313 |
6282 bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); } | 6314 bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); } |
6283 | 6315 |
6284 ACCESSORS(JSCollection, table, Object, kTableOffset) | 6316 ACCESSORS(JSCollection, table, Object, kTableOffset) |
6285 | 6317 |
6286 | 6318 |
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7843 #undef WRITE_INT64_FIELD | 7875 #undef WRITE_INT64_FIELD |
7844 #undef READ_BYTE_FIELD | 7876 #undef READ_BYTE_FIELD |
7845 #undef WRITE_BYTE_FIELD | 7877 #undef WRITE_BYTE_FIELD |
7846 #undef NOBARRIER_READ_BYTE_FIELD | 7878 #undef NOBARRIER_READ_BYTE_FIELD |
7847 #undef NOBARRIER_WRITE_BYTE_FIELD | 7879 #undef NOBARRIER_WRITE_BYTE_FIELD |
7848 | 7880 |
7849 } // namespace internal | 7881 } // namespace internal |
7850 } // namespace v8 | 7882 } // namespace v8 |
7851 | 7883 |
7852 #endif // V8_OBJECTS_INL_H_ | 7884 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |