Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/objects-inl.h

Issue 6597029: [Isolates] Merge r 6300:6500 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 } 2058 }
2059 2059
2060 2060
2061 void ExternalTwoByteString::set_resource( 2061 void ExternalTwoByteString::set_resource(
2062 ExternalTwoByteString::Resource* resource) { 2062 ExternalTwoByteString::Resource* resource) {
2063 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource; 2063 *reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset)) = resource;
2064 } 2064 }
2065 2065
2066 2066
2067 void JSFunctionResultCache::MakeZeroSize() { 2067 void JSFunctionResultCache::MakeZeroSize() {
2068 set(kFingerIndex, Smi::FromInt(kEntriesIndex)); 2068 set_finger_index(kEntriesIndex);
2069 set(kCacheSizeIndex, Smi::FromInt(kEntriesIndex)); 2069 set_size(kEntriesIndex);
2070 } 2070 }
2071 2071
2072 2072
2073 void JSFunctionResultCache::Clear() { 2073 void JSFunctionResultCache::Clear() {
2074 int cache_size = Smi::cast(get(kCacheSizeIndex))->value(); 2074 int cache_size = size();
2075 Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex)); 2075 Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex));
2076 MemsetPointer(entries_start, 2076 MemsetPointer(entries_start,
2077 GetHeap()->the_hole_value(), 2077 GetHeap()->the_hole_value(),
2078 cache_size - kEntriesIndex); 2078 cache_size - kEntriesIndex);
2079 MakeZeroSize(); 2079 MakeZeroSize();
2080 } 2080 }
2081 2081
2082 2082
2083 int JSFunctionResultCache::size() {
2084 return Smi::cast(get(kCacheSizeIndex))->value();
2085 }
2086
2087
2088 void JSFunctionResultCache::set_size(int size) {
2089 set(kCacheSizeIndex, Smi::FromInt(size));
2090 }
2091
2092
2093 int JSFunctionResultCache::finger_index() {
2094 return Smi::cast(get(kFingerIndex))->value();
2095 }
2096
2097
2098 void JSFunctionResultCache::set_finger_index(int finger_index) {
2099 set(kFingerIndex, Smi::FromInt(finger_index));
2100 }
2101
2102
2083 byte ByteArray::get(int index) { 2103 byte ByteArray::get(int index) {
2084 ASSERT(index >= 0 && index < this->length()); 2104 ASSERT(index >= 0 && index < this->length());
2085 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); 2105 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
2086 } 2106 }
2087 2107
2088 2108
2089 void ByteArray::set(int index, byte value) { 2109 void ByteArray::set(int index, byte value) {
2090 ASSERT(index >= 0 && index < this->length()); 2110 ASSERT(index >= 0 && index < this->length());
2091 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); 2111 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
2092 } 2112 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 // objects. This is used in the debugger to determine whether or not 2496 // objects. This is used in the debugger to determine whether or not
2477 // a call to code object has been replaced with a debug break call. 2497 // a call to code object has been replaced with a debug break call.
2478 ASSERT(is_inline_cache_stub() || 2498 ASSERT(is_inline_cache_stub() ||
2479 result == UNINITIALIZED || 2499 result == UNINITIALIZED ||
2480 result == DEBUG_BREAK || 2500 result == DEBUG_BREAK ||
2481 result == DEBUG_PREPARE_STEP_IN); 2501 result == DEBUG_PREPARE_STEP_IN);
2482 return result; 2502 return result;
2483 } 2503 }
2484 2504
2485 2505
2506 Code::ExtraICState Code::extra_ic_state() {
2507 ASSERT(is_inline_cache_stub());
2508 return ExtractExtraICStateFromFlags(flags());
2509 }
2510
2511
2486 PropertyType Code::type() { 2512 PropertyType Code::type() {
2487 ASSERT(ic_state() == MONOMORPHIC); 2513 ASSERT(ic_state() == MONOMORPHIC);
2488 return ExtractTypeFromFlags(flags()); 2514 return ExtractTypeFromFlags(flags());
2489 } 2515 }
2490 2516
2491 2517
2492 int Code::arguments_count() { 2518 int Code::arguments_count() {
2493 ASSERT(is_call_stub() || is_keyed_call_stub() || kind() == STUB); 2519 ASSERT(is_call_stub() || is_keyed_call_stub() || kind() == STUB);
2494 return ExtractArgumentsCountFromFlags(flags()); 2520 return ExtractArgumentsCountFromFlags(flags());
2495 } 2521 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 2678
2653 bool Code::is_inline_cache_stub() { 2679 bool Code::is_inline_cache_stub() {
2654 Kind kind = this->kind(); 2680 Kind kind = this->kind();
2655 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND; 2681 return kind >= FIRST_IC_KIND && kind <= LAST_IC_KIND;
2656 } 2682 }
2657 2683
2658 2684
2659 Code::Flags Code::ComputeFlags(Kind kind, 2685 Code::Flags Code::ComputeFlags(Kind kind,
2660 InLoopFlag in_loop, 2686 InLoopFlag in_loop,
2661 InlineCacheState ic_state, 2687 InlineCacheState ic_state,
2688 ExtraICState extra_ic_state,
2662 PropertyType type, 2689 PropertyType type,
2663 int argc, 2690 int argc,
2664 InlineCacheHolderFlag holder) { 2691 InlineCacheHolderFlag holder) {
2692 // Extra IC state is only allowed for monomorphic call IC stubs.
2693 ASSERT(extra_ic_state == kNoExtraICState ||
2694 (kind == CALL_IC && (ic_state == MONOMORPHIC ||
2695 ic_state == MONOMORPHIC_PROTOTYPE_FAILURE)));
2665 // Compute the bit mask. 2696 // Compute the bit mask.
2666 int bits = kind << kFlagsKindShift; 2697 int bits = kind << kFlagsKindShift;
2667 if (in_loop) bits |= kFlagsICInLoopMask; 2698 if (in_loop) bits |= kFlagsICInLoopMask;
2668 bits |= ic_state << kFlagsICStateShift; 2699 bits |= ic_state << kFlagsICStateShift;
2669 bits |= type << kFlagsTypeShift; 2700 bits |= type << kFlagsTypeShift;
2701 bits |= extra_ic_state << kFlagsExtraICStateShift;
2670 bits |= argc << kFlagsArgumentsCountShift; 2702 bits |= argc << kFlagsArgumentsCountShift;
2671 if (holder == PROTOTYPE_MAP) bits |= kFlagsCacheInPrototypeMapMask; 2703 if (holder == PROTOTYPE_MAP) bits |= kFlagsCacheInPrototypeMapMask;
2672 // Cast to flags and validate result before returning it. 2704 // Cast to flags and validate result before returning it.
2673 Flags result = static_cast<Flags>(bits); 2705 Flags result = static_cast<Flags>(bits);
2674 ASSERT(ExtractKindFromFlags(result) == kind); 2706 ASSERT(ExtractKindFromFlags(result) == kind);
2675 ASSERT(ExtractICStateFromFlags(result) == ic_state); 2707 ASSERT(ExtractICStateFromFlags(result) == ic_state);
2676 ASSERT(ExtractICInLoopFromFlags(result) == in_loop); 2708 ASSERT(ExtractICInLoopFromFlags(result) == in_loop);
2677 ASSERT(ExtractTypeFromFlags(result) == type); 2709 ASSERT(ExtractTypeFromFlags(result) == type);
2710 ASSERT(ExtractExtraICStateFromFlags(result) == extra_ic_state);
2678 ASSERT(ExtractArgumentsCountFromFlags(result) == argc); 2711 ASSERT(ExtractArgumentsCountFromFlags(result) == argc);
2679 return result; 2712 return result;
2680 } 2713 }
2681 2714
2682 2715
2683 Code::Flags Code::ComputeMonomorphicFlags(Kind kind, 2716 Code::Flags Code::ComputeMonomorphicFlags(Kind kind,
2684 PropertyType type, 2717 PropertyType type,
2718 ExtraICState extra_ic_state,
2685 InlineCacheHolderFlag holder, 2719 InlineCacheHolderFlag holder,
2686 InLoopFlag in_loop, 2720 InLoopFlag in_loop,
2687 int argc) { 2721 int argc) {
2688 return ComputeFlags(kind, in_loop, MONOMORPHIC, type, argc, holder); 2722 return ComputeFlags(
2723 kind, in_loop, MONOMORPHIC, extra_ic_state, type, argc, holder);
2689 } 2724 }
2690 2725
2691 2726
2692 Code::Kind Code::ExtractKindFromFlags(Flags flags) { 2727 Code::Kind Code::ExtractKindFromFlags(Flags flags) {
2693 int bits = (flags & kFlagsKindMask) >> kFlagsKindShift; 2728 int bits = (flags & kFlagsKindMask) >> kFlagsKindShift;
2694 return static_cast<Kind>(bits); 2729 return static_cast<Kind>(bits);
2695 } 2730 }
2696 2731
2697 2732
2698 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { 2733 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) {
2699 int bits = (flags & kFlagsICStateMask) >> kFlagsICStateShift; 2734 int bits = (flags & kFlagsICStateMask) >> kFlagsICStateShift;
2700 return static_cast<InlineCacheState>(bits); 2735 return static_cast<InlineCacheState>(bits);
2701 } 2736 }
2702 2737
2703 2738
2739 Code::ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) {
2740 int bits = (flags & kFlagsExtraICStateMask) >> kFlagsExtraICStateShift;
2741 return static_cast<ExtraICState>(bits);
2742 }
2743
2744
2704 InLoopFlag Code::ExtractICInLoopFromFlags(Flags flags) { 2745 InLoopFlag Code::ExtractICInLoopFromFlags(Flags flags) {
2705 int bits = (flags & kFlagsICInLoopMask); 2746 int bits = (flags & kFlagsICInLoopMask);
2706 return bits != 0 ? IN_LOOP : NOT_IN_LOOP; 2747 return bits != 0 ? IN_LOOP : NOT_IN_LOOP;
2707 } 2748 }
2708 2749
2709 2750
2710 PropertyType Code::ExtractTypeFromFlags(Flags flags) { 2751 PropertyType Code::ExtractTypeFromFlags(Flags flags) {
2711 int bits = (flags & kFlagsTypeMask) >> kFlagsTypeShift; 2752 int bits = (flags & kFlagsTypeMask) >> kFlagsTypeShift;
2712 return static_cast<PropertyType>(bits); 2753 return static_cast<PropertyType>(bits);
2713 } 2754 }
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 return Code::cast(READ_FIELD(this, kCodeOffset)); 3120 return Code::cast(READ_FIELD(this, kCodeOffset));
3080 } 3121 }
3081 3122
3082 3123
3083 Code* SharedFunctionInfo::unchecked_code() { 3124 Code* SharedFunctionInfo::unchecked_code() {
3084 return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset)); 3125 return reinterpret_cast<Code*>(READ_FIELD(this, kCodeOffset));
3085 } 3126 }
3086 3127
3087 3128
3088 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { 3129 void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) {
3089 // If optimization has been disabled for the shared function info,
3090 // reflect that in the code object so it will not be counted as
3091 // optimizable code.
3092 ASSERT(value->kind() != Code::FUNCTION ||
3093 !value->optimizable() ||
3094 this->code() == Isolate::Current()->builtins()->
3095 builtin(Builtins::Illegal) ||
3096 this->allows_lazy_compilation());
3097 WRITE_FIELD(this, kCodeOffset, value); 3130 WRITE_FIELD(this, kCodeOffset, value);
3098 ASSERT(!Isolate::Current()->heap()->InNewSpace(value)); 3131 ASSERT(!Isolate::Current()->heap()->InNewSpace(value));
3099 } 3132 }
3100 3133
3101 3134
3102 SerializedScopeInfo* SharedFunctionInfo::scope_info() { 3135 SerializedScopeInfo* SharedFunctionInfo::scope_info() {
3103 return reinterpret_cast<SerializedScopeInfo*>( 3136 return reinterpret_cast<SerializedScopeInfo*>(
3104 READ_FIELD(this, kScopeInfoOffset)); 3137 READ_FIELD(this, kScopeInfoOffset));
3105 } 3138 }
3106 3139
(...skipping 30 matching lines...) Expand all
3137 ASSERT(IsApiFunction()); 3170 ASSERT(IsApiFunction());
3138 return FunctionTemplateInfo::cast(function_data()); 3171 return FunctionTemplateInfo::cast(function_data());
3139 } 3172 }
3140 3173
3141 3174
3142 bool SharedFunctionInfo::HasBuiltinFunctionId() { 3175 bool SharedFunctionInfo::HasBuiltinFunctionId() {
3143 return function_data()->IsSmi(); 3176 return function_data()->IsSmi();
3144 } 3177 }
3145 3178
3146 3179
3147 bool SharedFunctionInfo::IsBuiltinMathFunction() {
3148 return HasBuiltinFunctionId() &&
3149 builtin_function_id() >= kFirstMathFunctionId;
3150 }
3151
3152
3153 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { 3180 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
3154 ASSERT(HasBuiltinFunctionId()); 3181 ASSERT(HasBuiltinFunctionId());
3155 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value()); 3182 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value());
3156 } 3183 }
3157 3184
3158 3185
3159 int SharedFunctionInfo::code_age() { 3186 int SharedFunctionInfo::code_age() {
3160 return (compiler_hints() >> kCodeAgeShift) & kCodeAgeMask; 3187 return (compiler_hints() >> kCodeAgeShift) & kCodeAgeMask;
3161 } 3188 }
3162 3189
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
4010 #undef WRITE_INT_FIELD 4037 #undef WRITE_INT_FIELD
4011 #undef READ_SHORT_FIELD 4038 #undef READ_SHORT_FIELD
4012 #undef WRITE_SHORT_FIELD 4039 #undef WRITE_SHORT_FIELD
4013 #undef READ_BYTE_FIELD 4040 #undef READ_BYTE_FIELD
4014 #undef WRITE_BYTE_FIELD 4041 #undef WRITE_BYTE_FIELD
4015 4042
4016 4043
4017 } } // namespace v8::internal 4044 } } // namespace v8::internal
4018 4045
4019 #endif // V8_OBJECTS_INL_H_ 4046 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698