OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 } | 1971 } |
1972 | 1972 |
1973 | 1973 |
1974 void ExternalTwoByteString::set_resource( | 1974 void ExternalTwoByteString::set_resource( |
1975 ExternalTwoByteString::Resource* resource) { | 1975 ExternalTwoByteString::Resource* resource) { |
1976 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; | 1976 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; |
1977 } | 1977 } |
1978 | 1978 |
1979 | 1979 |
1980 void JSFunctionResultCache::MakeZeroSize() { | 1980 void JSFunctionResultCache::MakeZeroSize() { |
1981 set(kFingerIndex, Smi::FromInt(kEntriesIndex)); | 1981 set_finger_index(kEntriesIndex); |
1982 set(kCacheSizeIndex, Smi::FromInt(kEntriesIndex)); | 1982 set_size(kEntriesIndex); |
1983 } | 1983 } |
1984 | 1984 |
1985 | 1985 |
1986 void JSFunctionResultCache::Clear() { | 1986 void JSFunctionResultCache::Clear() { |
1987 int cache_size = Smi::cast(get(kCacheSizeIndex))->value(); | 1987 int cache_size = size(); |
1988 Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex)); | 1988 Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex)); |
1989 MemsetPointer(entries_start, | 1989 MemsetPointer(entries_start, |
1990 Heap::the_hole_value(), | 1990 Heap::the_hole_value(), |
1991 cache_size - kEntriesIndex); | 1991 cache_size - kEntriesIndex); |
1992 MakeZeroSize(); | 1992 MakeZeroSize(); |
1993 } | 1993 } |
1994 | 1994 |
1995 | 1995 |
| 1996 int JSFunctionResultCache::size() { |
| 1997 return Smi::cast(get(kCacheSizeIndex))->value(); |
| 1998 } |
| 1999 |
| 2000 |
| 2001 void JSFunctionResultCache::set_size(int size) { |
| 2002 set(kCacheSizeIndex, Smi::FromInt(size)); |
| 2003 } |
| 2004 |
| 2005 |
| 2006 int JSFunctionResultCache::finger_index() { |
| 2007 return Smi::cast(get(kFingerIndex))->value(); |
| 2008 } |
| 2009 |
| 2010 |
| 2011 void JSFunctionResultCache::set_finger_index(int finger_index) { |
| 2012 set(kFingerIndex, Smi::FromInt(finger_index)); |
| 2013 } |
| 2014 |
| 2015 |
1996 byte ByteArray::get(int index) { | 2016 byte ByteArray::get(int index) { |
1997 ASSERT(index >= 0 && index < this->length()); | 2017 ASSERT(index >= 0 && index < this->length()); |
1998 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); | 2018 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
1999 } | 2019 } |
2000 | 2020 |
2001 | 2021 |
2002 void ByteArray::set(int index, byte value) { | 2022 void ByteArray::set(int index, byte value) { |
2003 ASSERT(index >= 0 && index < this->length()); | 2023 ASSERT(index >= 0 && index < this->length()); |
2004 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); | 2024 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); |
2005 } | 2025 } |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2389 // objects. This is used in the debugger to determine whether or not | 2409 // objects. This is used in the debugger to determine whether or not |
2390 // a call to code object has been replaced with a debug break call. | 2410 // a call to code object has been replaced with a debug break call. |
2391 ASSERT(is_inline_cache_stub() || | 2411 ASSERT(is_inline_cache_stub() || |
2392 result == UNINITIALIZED || | 2412 result == UNINITIALIZED || |
2393 result == DEBUG_BREAK || | 2413 result == DEBUG_BREAK || |
2394 result == DEBUG_PREPARE_STEP_IN); | 2414 result == DEBUG_PREPARE_STEP_IN); |
2395 return result; | 2415 return result; |
2396 } | 2416 } |
2397 | 2417 |
2398 | 2418 |
| 2419 Code::ExtraICState Code::extra_ic_state() { |
| 2420 ASSERT(is_inline_cache_stub()); |
| 2421 return ExtractExtraICStateFromFlags(flags()); |
| 2422 } |
| 2423 |
| 2424 |
2399 PropertyType Code::type() { | 2425 PropertyType Code::type() { |
2400 ASSERT(ic_state() == MONOMORPHIC); | 2426 ASSERT(ic_state() == MONOMORPHIC); |
2401 return ExtractTypeFromFlags(flags()); | 2427 return ExtractTypeFromFlags(flags()); |
2402 } | 2428 } |
2403 | 2429 |
2404 | 2430 |
2405 int Code::arguments_count() { | 2431 int Code::arguments_count() { |
2406 ASSERT(is_call_stub() || is_keyed_call_stub() || kind() == STUB); | 2432 ASSERT(is_call_stub() || is_keyed_call_stub() || kind() == STUB); |
2407 return ExtractArgumentsCountFromFlags(flags()); | 2433 return ExtractArgumentsCountFromFlags(flags()); |
2408 } | 2434 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 | 2591 |
2566 bool Code::is_inline_cache_stub() { | 2592 bool Code::is_inline_cache_stub() { |
2567 Kind kind = this->kind(); | 2593 Kind kind = this->kind(); |
2568 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; | 2594 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; |
2569 } | 2595 } |
2570 | 2596 |
2571 | 2597 |
2572 Code::Flags Code::ComputeFlags(Kind kind, | 2598 Code::Flags Code::ComputeFlags(Kind kind, |
2573 InLoopFlag in_loop, | 2599 InLoopFlag in_loop, |
2574 InlineCacheState ic_state, | 2600 InlineCacheState ic_state, |
| 2601 ExtraICState extra_ic_state, |
2575 PropertyType type, | 2602 PropertyType type, |
2576 int argc, | 2603 int argc, |
2577 InlineCacheHolderFlag holder) { | 2604 InlineCacheHolderFlag holder) { |
| 2605 // Extra IC state is only allowed for monomorphic call IC stubs. |
| 2606 ASSERT(extra_ic_state == kNoExtraICState || |
| 2607 (kind == CALL_IC && (ic_state == MONOMORPHIC || |
| 2608 ic_state == MONOMORPHIC_PROTOTYPE_FAILURE))); |
2578 // Compute the bit mask. | 2609 // Compute the bit mask. |
2579 int bits = kind << kFlagsKindShift; | 2610 int bits = kind << kFlagsKindShift; |
2580 if (in_loop) bits |= kFlagsICInLoopMask; | 2611 if (in_loop) bits |= kFlagsICInLoopMask; |
2581 bits |= ic_state << kFlagsICStateShift; | 2612 bits |= ic_state << kFlagsICStateShift; |
2582 bits |= type << kFlagsTypeShift; | 2613 bits |= type << kFlagsTypeShift; |
| 2614 bits |= extra_ic_state << kFlagsExtraICStateShift; |
2583 bits |= argc << kFlagsArgumentsCountShift; | 2615 bits |= argc << kFlagsArgumentsCountShift; |
2584 if (holder == PROTOTYPE_MAP) bits |= kFlagsCacheInPrototypeMapMask; | 2616 if (holder == PROTOTYPE_MAP) bits |= kFlagsCacheInPrototypeMapMask; |
2585 // Cast to flags and validate result before returning it. | 2617 // Cast to flags and validate result before returning it. |
2586 Flags result = static_cast<Flags>(bits); | 2618 Flags result = static_cast<Flags>(bits); |
2587 ASSERT(ExtractKindFromFlags(result) == kind); | 2619 ASSERT(ExtractKindFromFlags(result) == kind); |
2588 ASSERT(ExtractICStateFromFlags(result) == ic_state); | 2620 ASSERT(ExtractICStateFromFlags(result) == ic_state); |
2589 ASSERT(ExtractICInLoopFromFlags(result) == in_loop); | 2621 ASSERT(ExtractICInLoopFromFlags(result) == in_loop); |
2590 ASSERT(ExtractTypeFromFlags(result) == type); | 2622 ASSERT(ExtractTypeFromFlags(result) == type); |
| 2623 ASSERT(ExtractExtraICStateFromFlags(result) == extra_ic_state); |
2591 ASSERT(ExtractArgumentsCountFromFlags(result) == argc); | 2624 ASSERT(ExtractArgumentsCountFromFlags(result) == argc); |
2592 return result; | 2625 return result; |
2593 } | 2626 } |
2594 | 2627 |
2595 | 2628 |
2596 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, | 2629 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, |
2597 PropertyType type, | 2630 PropertyType type, |
| 2631 ExtraICState extra_ic_state, |
2598 InlineCacheHolderFlag holder, | 2632 InlineCacheHolderFlag holder, |
2599 InLoopFlag in_loop, | 2633 InLoopFlag in_loop, |
2600 int argc) { | 2634 int argc) { |
2601 return ComputeFlags(kind, in_loop, MONOMORPHIC, type, argc, holder); | 2635 return ComputeFlags( |
| 2636 kind, in_loop, MONOMORPHIC, extra_ic_state, type, argc, holder); |
2602 } | 2637 } |
2603 | 2638 |
2604 | 2639 |
2605 Code::Kind Code::ExtractKindFromFlags(Flags flags) { | 2640 Code::Kind Code::ExtractKindFromFlags(Flags flags) { |
2606 int bits = (flags & kFlagsKindMask) >> kFlagsKindShift; | 2641 int bits = (flags & kFlagsKindMask) >> kFlagsKindShift; |
2607 return static_cast<Kind>(bits); | 2642 return static_cast<Kind>(bits); |
2608 } | 2643 } |
2609 | 2644 |
2610 | 2645 |
2611 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { | 2646 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { |
2612 int bits = (flags & kFlagsICStateMask) >> kFlagsICStateShift; | 2647 int bits = (flags & kFlagsICStateMask) >> kFlagsICStateShift; |
2613 return static_cast<InlineCacheState>(bits); | 2648 return static_cast<InlineCacheState>(bits); |
2614 } | 2649 } |
2615 | 2650 |
2616 | 2651 |
| 2652 Code::ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { |
| 2653 int bits = (flags & kFlagsExtraICStateMask) >> kFlagsExtraICStateShift; |
| 2654 return static_cast<ExtraICState>(bits); |
| 2655 } |
| 2656 |
| 2657 |
2617 InLoopFlag Code::ExtractICInLoopFromFlags(Flags flags) { | 2658 InLoopFlag Code::ExtractICInLoopFromFlags(Flags flags) { |
2618 int bits = (flags & kFlagsICInLoopMask); | 2659 int bits = (flags & kFlagsICInLoopMask); |
2619 return bits != 0 ? IN_LOOP : NOT_IN_LOOP; | 2660 return bits != 0 ? IN_LOOP : NOT_IN_LOOP; |
2620 } | 2661 } |
2621 | 2662 |
2622 | 2663 |
2623 PropertyType Code::ExtractTypeFromFlags(Flags flags) { | 2664 PropertyType Code::ExtractTypeFromFlags(Flags flags) { |
2624 int bits = (flags & kFlagsTypeMask) >> kFlagsTypeShift; | 2665 int bits = (flags & kFlagsTypeMask) >> kFlagsTypeShift; |
2625 return static_cast<PropertyType>(bits); | 2666 return static_cast<PropertyType>(bits); |
2626 } | 2667 } |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3842 #undef WRITE_INT_FIELD | 3883 #undef WRITE_INT_FIELD |
3843 #undef READ_SHORT_FIELD | 3884 #undef READ_SHORT_FIELD |
3844 #undef WRITE_SHORT_FIELD | 3885 #undef WRITE_SHORT_FIELD |
3845 #undef READ_BYTE_FIELD | 3886 #undef READ_BYTE_FIELD |
3846 #undef WRITE_BYTE_FIELD | 3887 #undef WRITE_BYTE_FIELD |
3847 | 3888 |
3848 | 3889 |
3849 } } // namespace v8::internal | 3890 } } // namespace v8::internal |
3850 | 3891 |
3851 #endif // V8_OBJECTS_INL_H_ | 3892 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |