OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 bool Object::IsDeoptimizationOutputData() { | 577 bool Object::IsDeoptimizationOutputData() { |
578 if (!IsFixedArray()) return false; | 578 if (!IsFixedArray()) return false; |
579 // There's actually no way to see the difference between a fixed array and | 579 // There's actually no way to see the difference between a fixed array and |
580 // a deoptimization data array. Since this is used for asserts we can check | 580 // a deoptimization data array. Since this is used for asserts we can check |
581 // that the length is plausible though. | 581 // that the length is plausible though. |
582 if (FixedArray::cast(this)->length() % 2 != 0) return false; | 582 if (FixedArray::cast(this)->length() % 2 != 0) return false; |
583 return true; | 583 return true; |
584 } | 584 } |
585 | 585 |
586 | 586 |
587 bool Object::IsDependentCodes() { | 587 bool Object::IsDependentCode() { |
588 if (!IsFixedArray()) return false; | 588 if (!IsFixedArray()) return false; |
589 // There's actually no way to see the difference between a fixed array and | 589 // There's actually no way to see the difference between a fixed array and |
590 // a dependent codes array. | 590 // a dependent codes array. |
591 return true; | 591 return true; |
592 } | 592 } |
593 | 593 |
594 | 594 |
595 bool Object::IsTypeFeedbackCells() { | 595 bool Object::IsTypeFeedbackCells() { |
596 if (!IsFixedArray()) return false; | 596 if (!IsFixedArray()) return false; |
597 // There's actually no way to see the difference between a fixed array and | 597 // There's actually no way to see the difference between a fixed array and |
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 | 2385 |
2386 // ------------------------------------ | 2386 // ------------------------------------ |
2387 // Cast operations | 2387 // Cast operations |
2388 | 2388 |
2389 | 2389 |
2390 CAST_ACCESSOR(FixedArray) | 2390 CAST_ACCESSOR(FixedArray) |
2391 CAST_ACCESSOR(FixedDoubleArray) | 2391 CAST_ACCESSOR(FixedDoubleArray) |
2392 CAST_ACCESSOR(DescriptorArray) | 2392 CAST_ACCESSOR(DescriptorArray) |
2393 CAST_ACCESSOR(DeoptimizationInputData) | 2393 CAST_ACCESSOR(DeoptimizationInputData) |
2394 CAST_ACCESSOR(DeoptimizationOutputData) | 2394 CAST_ACCESSOR(DeoptimizationOutputData) |
2395 CAST_ACCESSOR(DependentCodes) | 2395 CAST_ACCESSOR(DependentCode) |
2396 CAST_ACCESSOR(TypeFeedbackCells) | 2396 CAST_ACCESSOR(TypeFeedbackCells) |
2397 CAST_ACCESSOR(SymbolTable) | 2397 CAST_ACCESSOR(SymbolTable) |
2398 CAST_ACCESSOR(JSFunctionResultCache) | 2398 CAST_ACCESSOR(JSFunctionResultCache) |
2399 CAST_ACCESSOR(NormalizedMapCache) | 2399 CAST_ACCESSOR(NormalizedMapCache) |
2400 CAST_ACCESSOR(ScopeInfo) | 2400 CAST_ACCESSOR(ScopeInfo) |
2401 CAST_ACCESSOR(CompilationCacheTable) | 2401 CAST_ACCESSOR(CompilationCacheTable) |
2402 CAST_ACCESSOR(CodeCacheHashTable) | 2402 CAST_ACCESSOR(CodeCacheHashTable) |
2403 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) | 2403 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) |
2404 CAST_ACCESSOR(MapCache) | 2404 CAST_ACCESSOR(MapCache) |
2405 CAST_ACCESSOR(String) | 2405 CAST_ACCESSOR(String) |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 has_slow_elements_kind() || has_external_array_elements()); | 3418 has_slow_elements_kind() || has_external_array_elements()); |
3419 set_bit_field3(IsObserved::update(bit_field3(), is_observed)); | 3419 set_bit_field3(IsObserved::update(bit_field3(), is_observed)); |
3420 } | 3420 } |
3421 | 3421 |
3422 | 3422 |
3423 bool Map::is_observed() { | 3423 bool Map::is_observed() { |
3424 return IsObserved::decode(bit_field3()); | 3424 return IsObserved::decode(bit_field3()); |
3425 } | 3425 } |
3426 | 3426 |
3427 | 3427 |
3428 void Map::AddDependentCode(Handle<Code> code) { | 3428 void Map::NotifyObjectLayoutChange() { |
3429 Handle<DependentCodes> codes = | 3429 dependent_code()->DeoptimizeDependentCodeGroup( |
3430 DependentCodes::Append(Handle<DependentCodes>(dependent_codes()), code); | 3430 DependentCode::kPrototypeCheckGroup); |
3431 if (*codes != dependent_codes()) { | 3431 } |
3432 set_dependent_codes(*codes); | 3432 |
| 3433 |
| 3434 bool Map::CanOmitPrototypeChecks() { |
| 3435 return !HasTransitionArray() && !is_dictionary_map(); |
| 3436 } |
| 3437 |
| 3438 |
| 3439 void Map::AddDependentCode(DependentCode::DependencyGroup group, |
| 3440 Handle<Code> code) { |
| 3441 Handle<DependentCode> codes = |
| 3442 DependentCode::Insert(Handle<DependentCode>(dependent_code()), |
| 3443 group, code); |
| 3444 if (*codes != dependent_code()) { |
| 3445 set_dependent_code(*codes); |
3433 } | 3446 } |
3434 } | 3447 } |
3435 | 3448 |
3436 | 3449 |
3437 int DependentCodes::number_of_codes() { | 3450 int DependentCode::number_of_codes(DependencyGroup group) { |
3438 if (length() == 0) return 0; | 3451 if (length() == 0) return 0; |
3439 return Smi::cast(get(kNumberOfCodesIndex))->value(); | 3452 return Smi::cast(get(group))->value(); |
3440 } | 3453 } |
3441 | 3454 |
3442 | 3455 |
3443 void DependentCodes::set_number_of_codes(int value) { | 3456 void DependentCode::set_number_of_codes(DependencyGroup group, int value) { |
3444 set(kNumberOfCodesIndex, Smi::FromInt(value)); | 3457 set(group, Smi::FromInt(value)); |
3445 } | 3458 } |
3446 | 3459 |
3447 | 3460 |
3448 Code* DependentCodes::code_at(int i) { | 3461 Code* DependentCode::code_at(int i) { |
3449 return Code::cast(get(kCodesIndex + i)); | 3462 return Code::cast(get(kCodesStartIndex + i)); |
3450 } | 3463 } |
3451 | 3464 |
3452 | 3465 |
3453 void DependentCodes::set_code_at(int i, Code* value) { | 3466 void DependentCode::set_code_at(int i, Code* value) { |
3454 set(kCodesIndex + i, value); | 3467 set(kCodesStartIndex + i, value); |
3455 } | 3468 } |
3456 | 3469 |
3457 | 3470 |
3458 Object** DependentCodes::code_slot_at(int i) { | 3471 Object** DependentCode::code_slot_at(int i) { |
3459 return HeapObject::RawField( | 3472 return HeapObject::RawField( |
3460 this, FixedArray::OffsetOfElementAt(kCodesIndex + i)); | 3473 this, FixedArray::OffsetOfElementAt(kCodesStartIndex + i)); |
3461 } | 3474 } |
3462 | 3475 |
3463 | 3476 |
3464 void DependentCodes::clear_code_at(int i) { | 3477 void DependentCode::clear_code_at(int i) { |
3465 set_undefined(kCodesIndex + i); | 3478 set_undefined(kCodesStartIndex + i); |
3466 } | 3479 } |
3467 | 3480 |
3468 | 3481 |
| 3482 void DependentCode::ExtendGroup(DependencyGroup group) { |
| 3483 GroupStartIndexes starts(this); |
| 3484 for (int g = kGroupCount - 1; g > group; g--) { |
| 3485 if (starts.at(g) < starts.at(g + 1)) { |
| 3486 set_code_at(starts.at(g + 1), code_at(starts.at(g))); |
| 3487 } |
| 3488 } |
| 3489 } |
| 3490 |
| 3491 |
3469 void Code::set_flags(Code::Flags flags) { | 3492 void Code::set_flags(Code::Flags flags) { |
3470 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); | 3493 STATIC_ASSERT(Code::NUMBER_OF_KINDS <= KindField::kMax + 1); |
3471 // Make sure that all call stubs have an arguments count. | 3494 // Make sure that all call stubs have an arguments count. |
3472 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && | 3495 ASSERT((ExtractKindFromFlags(flags) != CALL_IC && |
3473 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || | 3496 ExtractKindFromFlags(flags) != KEYED_CALL_IC) || |
3474 ExtractArgumentsCountFromFlags(flags) >= 0); | 3497 ExtractArgumentsCountFromFlags(flags) >= 0); |
3475 WRITE_INT_FIELD(this, kFlagsOffset, flags); | 3498 WRITE_INT_FIELD(this, kFlagsOffset, flags); |
3476 } | 3499 } |
3477 | 3500 |
3478 | 3501 |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4081 | 4104 |
4082 | 4105 |
4083 HeapObject* Map::UncheckedPrototypeTransitions() { | 4106 HeapObject* Map::UncheckedPrototypeTransitions() { |
4084 ASSERT(HasTransitionArray()); | 4107 ASSERT(HasTransitionArray()); |
4085 ASSERT(unchecked_transition_array()->HasPrototypeTransitions()); | 4108 ASSERT(unchecked_transition_array()->HasPrototypeTransitions()); |
4086 return unchecked_transition_array()->UncheckedPrototypeTransitions(); | 4109 return unchecked_transition_array()->UncheckedPrototypeTransitions(); |
4087 } | 4110 } |
4088 | 4111 |
4089 | 4112 |
4090 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) | 4113 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) |
4091 ACCESSORS(Map, dependent_codes, DependentCodes, kDependentCodesOffset) | 4114 ACCESSORS(Map, dependent_code, DependentCode, kDependentCodeOffset) |
4092 ACCESSORS(Map, constructor, Object, kConstructorOffset) | 4115 ACCESSORS(Map, constructor, Object, kConstructorOffset) |
4093 | 4116 |
4094 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 4117 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
4095 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) | 4118 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) |
4096 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) | 4119 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) |
4097 | 4120 |
4098 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 4121 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
4099 ACCESSORS(GlobalObject, native_context, Context, kNativeContextOffset) | 4122 ACCESSORS(GlobalObject, native_context, Context, kNativeContextOffset) |
4100 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) | 4123 ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) |
4101 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) | 4124 ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) |
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5890 #undef WRITE_UINT32_FIELD | 5913 #undef WRITE_UINT32_FIELD |
5891 #undef READ_SHORT_FIELD | 5914 #undef READ_SHORT_FIELD |
5892 #undef WRITE_SHORT_FIELD | 5915 #undef WRITE_SHORT_FIELD |
5893 #undef READ_BYTE_FIELD | 5916 #undef READ_BYTE_FIELD |
5894 #undef WRITE_BYTE_FIELD | 5917 #undef WRITE_BYTE_FIELD |
5895 | 5918 |
5896 | 5919 |
5897 } } // namespace v8::internal | 5920 } } // namespace v8::internal |
5898 | 5921 |
5899 #endif // V8_OBJECTS_INL_H_ | 5922 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |