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 3373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3384 } | 3384 } |
3385 | 3385 |
3386 | 3386 |
3387 LiteralsArray* LiteralsArray::cast(Object* object) { | 3387 LiteralsArray* LiteralsArray::cast(Object* object) { |
3388 SLOW_DCHECK(object->IsLiteralsArray()); | 3388 SLOW_DCHECK(object->IsLiteralsArray()); |
3389 return reinterpret_cast<LiteralsArray*>(object); | 3389 return reinterpret_cast<LiteralsArray*>(object); |
3390 } | 3390 } |
3391 | 3391 |
3392 | 3392 |
3393 TypeFeedbackVector* LiteralsArray::feedback_vector() const { | 3393 TypeFeedbackVector* LiteralsArray::feedback_vector() const { |
| 3394 if (length() == 0) { |
| 3395 return TypeFeedbackVector::cast( |
| 3396 const_cast<FixedArray*>(FixedArray::cast(this))); |
| 3397 } |
3394 return TypeFeedbackVector::cast(get(kVectorIndex)); | 3398 return TypeFeedbackVector::cast(get(kVectorIndex)); |
3395 } | 3399 } |
3396 | 3400 |
3397 | 3401 |
3398 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { | 3402 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { |
| 3403 if (length() <= kVectorIndex) { |
| 3404 DCHECK(vector->length() == 0); |
| 3405 return; |
| 3406 } |
3399 set(kVectorIndex, vector); | 3407 set(kVectorIndex, vector); |
3400 } | 3408 } |
3401 | 3409 |
3402 | 3410 |
3403 Object* LiteralsArray::literal(int literal_index) const { | 3411 Object* LiteralsArray::literal(int literal_index) const { |
3404 return get(kFirstLiteralIndex + literal_index); | 3412 return get(kFirstLiteralIndex + literal_index); |
3405 } | 3413 } |
3406 | 3414 |
3407 | 3415 |
3408 void LiteralsArray::set_literal(int literal_index, Object* literal) { | 3416 void LiteralsArray::set_literal(int literal_index, Object* literal) { |
3409 set(kFirstLiteralIndex + literal_index, literal); | 3417 set(kFirstLiteralIndex + literal_index, literal); |
3410 } | 3418 } |
3411 | 3419 |
| 3420 void LiteralsArray::set_literal_undefined(int literal_index) { |
| 3421 set_undefined(kFirstLiteralIndex + literal_index); |
| 3422 } |
3412 | 3423 |
3413 int LiteralsArray::literals_count() const { | 3424 int LiteralsArray::literals_count() const { |
3414 return length() - kFirstLiteralIndex; | 3425 return length() - kFirstLiteralIndex; |
3415 } | 3426 } |
3416 | 3427 |
3417 | 3428 |
3418 void HandlerTable::SetRangeStart(int index, int value) { | 3429 void HandlerTable::SetRangeStart(int index, int value) { |
3419 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value)); | 3430 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value)); |
3420 } | 3431 } |
3421 | 3432 |
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5608 | 5619 |
5609 SMI_ACCESSORS(BreakPointInfo, code_position, kCodePositionIndex) | 5620 SMI_ACCESSORS(BreakPointInfo, code_position, kCodePositionIndex) |
5610 SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionIndex) | 5621 SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionIndex) |
5611 SMI_ACCESSORS(BreakPointInfo, statement_position, kStatementPositionIndex) | 5622 SMI_ACCESSORS(BreakPointInfo, statement_position, kStatementPositionIndex) |
5612 ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex) | 5623 ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex) |
5613 | 5624 |
5614 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) | 5625 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) |
5615 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, | 5626 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, |
5616 kOptimizedCodeMapOffset) | 5627 kOptimizedCodeMapOffset) |
5617 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) | 5628 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) |
5618 ACCESSORS(SharedFunctionInfo, feedback_vector, TypeFeedbackVector, | 5629 ACCESSORS(SharedFunctionInfo, feedback_metadata, TypeFeedbackMetadata, |
5619 kFeedbackVectorOffset) | 5630 kFeedbackMetadataOffset) |
5620 #if TRACE_MAPS | 5631 #if TRACE_MAPS |
5621 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset) | 5632 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset) |
5622 #endif | 5633 #endif |
5623 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, | 5634 ACCESSORS(SharedFunctionInfo, instance_class_name, Object, |
5624 kInstanceClassNameOffset) | 5635 kInstanceClassNameOffset) |
5625 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) | 5636 ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset) |
5626 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) | 5637 ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset) |
5627 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) | 5638 ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) |
5628 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) | 5639 ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) |
5629 | 5640 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5791 } | 5802 } |
5792 | 5803 |
5793 | 5804 |
5794 void SharedFunctionInfo::set_kind(FunctionKind kind) { | 5805 void SharedFunctionInfo::set_kind(FunctionKind kind) { |
5795 DCHECK(IsValidFunctionKind(kind)); | 5806 DCHECK(IsValidFunctionKind(kind)); |
5796 int hints = compiler_hints(); | 5807 int hints = compiler_hints(); |
5797 hints = FunctionKindBits::update(hints, kind); | 5808 hints = FunctionKindBits::update(hints, kind); |
5798 set_compiler_hints(hints); | 5809 set_compiler_hints(hints); |
5799 } | 5810 } |
5800 | 5811 |
| 5812 // static |
| 5813 int SharedFunctionInfo::OffsetToPreviousContext() { |
| 5814 return FixedArray::kHeaderSize + |
| 5815 kPointerSize * (kContextOffset - kEntryLength); |
| 5816 } |
| 5817 |
| 5818 int SharedFunctionInfo::OffsetToPreviousCachedCode() { |
| 5819 return FixedArray::kHeaderSize + |
| 5820 kPointerSize * (kCachedCodeOffset - kEntryLength); |
| 5821 } |
| 5822 |
| 5823 int SharedFunctionInfo::OffsetToPreviousLiterals() { |
| 5824 return FixedArray::kHeaderSize + |
| 5825 kPointerSize * (kLiteralsOffset - kEntryLength); |
| 5826 } |
| 5827 |
| 5828 int SharedFunctionInfo::OffsetToPreviousOsrAstId() { |
| 5829 return FixedArray::kHeaderSize + |
| 5830 kPointerSize * (kOsrAstIdOffset - kEntryLength); |
| 5831 } |
5801 | 5832 |
5802 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object, | 5833 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, needs_home_object, |
5803 kNeedsHomeObject) | 5834 kNeedsHomeObject) |
5804 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) | 5835 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) |
5805 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline) | 5836 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, force_inline, kForceInline) |
5806 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, | 5837 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, |
5807 name_should_print_as_anonymous, | 5838 name_should_print_as_anonymous, |
5808 kNameShouldPrintAsAnonymous) | 5839 kNameShouldPrintAsAnonymous) |
5809 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) | 5840 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous) |
5810 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction) | 5841 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction) |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6242 } | 6273 } |
6243 | 6274 |
6244 | 6275 |
6245 bool JSFunction::is_compiled() { | 6276 bool JSFunction::is_compiled() { |
6246 Builtins* builtins = GetIsolate()->builtins(); | 6277 Builtins* builtins = GetIsolate()->builtins(); |
6247 return code() != builtins->builtin(Builtins::kCompileLazy) && | 6278 return code() != builtins->builtin(Builtins::kCompileLazy) && |
6248 code() != builtins->builtin(Builtins::kCompileOptimized) && | 6279 code() != builtins->builtin(Builtins::kCompileOptimized) && |
6249 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent); | 6280 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent); |
6250 } | 6281 } |
6251 | 6282 |
| 6283 TypeFeedbackVector* JSFunction::feedback_vector() { |
| 6284 LiteralsArray* array = literals(); |
| 6285 return array->feedback_vector(); |
| 6286 } |
6252 | 6287 |
6253 int JSFunction::NumberOfLiterals() { | 6288 int JSFunction::NumberOfLiterals() { |
6254 return literals()->length(); | 6289 return literals()->length(); |
6255 } | 6290 } |
6256 | 6291 |
6257 | 6292 |
6258 ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset) | 6293 ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset) |
6259 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) | 6294 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) |
6260 ACCESSORS(JSProxy, hash, Object, kHashOffset) | 6295 ACCESSORS(JSProxy, hash, Object, kHashOffset) |
6261 | 6296 |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7812 #undef WRITE_INT64_FIELD | 7847 #undef WRITE_INT64_FIELD |
7813 #undef READ_BYTE_FIELD | 7848 #undef READ_BYTE_FIELD |
7814 #undef WRITE_BYTE_FIELD | 7849 #undef WRITE_BYTE_FIELD |
7815 #undef NOBARRIER_READ_BYTE_FIELD | 7850 #undef NOBARRIER_READ_BYTE_FIELD |
7816 #undef NOBARRIER_WRITE_BYTE_FIELD | 7851 #undef NOBARRIER_WRITE_BYTE_FIELD |
7817 | 7852 |
7818 } // namespace internal | 7853 } // namespace internal |
7819 } // namespace v8 | 7854 } // namespace v8 |
7820 | 7855 |
7821 #endif // V8_OBJECTS_INL_H_ | 7856 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |