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

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

Issue 23468021: move HEAP to /test (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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/profile-generator.h » ('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 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 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 1956 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
1957 } 1957 }
1958 1958
1959 1959
1960 bool FixedArray::is_the_hole(int index) { 1960 bool FixedArray::is_the_hole(int index) {
1961 return get(index) == GetHeap()->the_hole_value(); 1961 return get(index) == GetHeap()->the_hole_value();
1962 } 1962 }
1963 1963
1964 1964
1965 void FixedArray::set(int index, Smi* value) { 1965 void FixedArray::set(int index, Smi* value) {
1966 ASSERT(map() != HEAP->fixed_cow_array_map()); 1966 ASSERT(map() != GetHeap()->fixed_cow_array_map());
1967 ASSERT(index >= 0 && index < this->length()); 1967 ASSERT(index >= 0 && index < this->length());
1968 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); 1968 ASSERT(reinterpret_cast<Object*>(value)->IsSmi());
1969 int offset = kHeaderSize + index * kPointerSize; 1969 int offset = kHeaderSize + index * kPointerSize;
1970 WRITE_FIELD(this, offset, value); 1970 WRITE_FIELD(this, offset, value);
1971 } 1971 }
1972 1972
1973 1973
1974 void FixedArray::set(int index, Object* value) { 1974 void FixedArray::set(int index, Object* value) {
1975 ASSERT(map() != HEAP->fixed_cow_array_map()); 1975 ASSERT(map() != GetHeap()->fixed_cow_array_map());
1976 ASSERT(index >= 0 && index < this->length()); 1976 ASSERT(index >= 0 && index < this->length());
1977 int offset = kHeaderSize + index * kPointerSize; 1977 int offset = kHeaderSize + index * kPointerSize;
1978 WRITE_FIELD(this, offset, value); 1978 WRITE_FIELD(this, offset, value);
1979 WRITE_BARRIER(GetHeap(), this, offset, value); 1979 WRITE_BARRIER(GetHeap(), this, offset, value);
1980 } 1980 }
1981 1981
1982 1982
1983 inline bool FixedDoubleArray::is_the_hole_nan(double value) { 1983 inline bool FixedDoubleArray::is_the_hole_nan(double value) {
1984 return BitCast<uint64_t, double>(value) == kHoleNanInt64; 1984 return BitCast<uint64_t, double>(value) == kHoleNanInt64;
1985 } 1985 }
1986 1986
1987 1987
1988 inline double FixedDoubleArray::hole_nan_as_double() { 1988 inline double FixedDoubleArray::hole_nan_as_double() {
1989 return BitCast<double, uint64_t>(kHoleNanInt64); 1989 return BitCast<double, uint64_t>(kHoleNanInt64);
1990 } 1990 }
1991 1991
1992 1992
1993 inline double FixedDoubleArray::canonical_not_the_hole_nan_as_double() { 1993 inline double FixedDoubleArray::canonical_not_the_hole_nan_as_double() {
1994 ASSERT(BitCast<uint64_t>(OS::nan_value()) != kHoleNanInt64); 1994 ASSERT(BitCast<uint64_t>(OS::nan_value()) != kHoleNanInt64);
1995 ASSERT((BitCast<uint64_t>(OS::nan_value()) >> 32) != kHoleNanUpper32); 1995 ASSERT((BitCast<uint64_t>(OS::nan_value()) >> 32) != kHoleNanUpper32);
1996 return OS::nan_value(); 1996 return OS::nan_value();
1997 } 1997 }
1998 1998
1999 1999
2000 double FixedDoubleArray::get_scalar(int index) { 2000 double FixedDoubleArray::get_scalar(int index) {
2001 ASSERT(map() != HEAP->fixed_cow_array_map() && 2001 ASSERT(map() != GetHeap()->fixed_cow_array_map() &&
2002 map() != HEAP->fixed_array_map()); 2002 map() != GetHeap()->fixed_array_map());
2003 ASSERT(index >= 0 && index < this->length()); 2003 ASSERT(index >= 0 && index < this->length());
2004 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); 2004 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize);
2005 ASSERT(!is_the_hole_nan(result)); 2005 ASSERT(!is_the_hole_nan(result));
2006 return result; 2006 return result;
2007 } 2007 }
2008 2008
2009 int64_t FixedDoubleArray::get_representation(int index) { 2009 int64_t FixedDoubleArray::get_representation(int index) {
2010 ASSERT(map() != HEAP->fixed_cow_array_map() && 2010 ASSERT(map() != GetHeap()->fixed_cow_array_map() &&
2011 map() != HEAP->fixed_array_map()); 2011 map() != GetHeap()->fixed_array_map());
2012 ASSERT(index >= 0 && index < this->length()); 2012 ASSERT(index >= 0 && index < this->length());
2013 return READ_INT64_FIELD(this, kHeaderSize + index * kDoubleSize); 2013 return READ_INT64_FIELD(this, kHeaderSize + index * kDoubleSize);
2014 } 2014 }
2015 2015
2016 MaybeObject* FixedDoubleArray::get(int index) { 2016 MaybeObject* FixedDoubleArray::get(int index) {
2017 if (is_the_hole(index)) { 2017 if (is_the_hole(index)) {
2018 return GetHeap()->the_hole_value(); 2018 return GetHeap()->the_hole_value();
2019 } else { 2019 } else {
2020 return GetHeap()->NumberFromDouble(get_scalar(index)); 2020 return GetHeap()->NumberFromDouble(get_scalar(index));
2021 } 2021 }
2022 } 2022 }
2023 2023
2024 2024
2025 void FixedDoubleArray::set(int index, double value) { 2025 void FixedDoubleArray::set(int index, double value) {
2026 ASSERT(map() != HEAP->fixed_cow_array_map() && 2026 ASSERT(map() != GetHeap()->fixed_cow_array_map() &&
2027 map() != HEAP->fixed_array_map()); 2027 map() != GetHeap()->fixed_array_map());
2028 int offset = kHeaderSize + index * kDoubleSize; 2028 int offset = kHeaderSize + index * kDoubleSize;
2029 if (std::isnan(value)) value = canonical_not_the_hole_nan_as_double(); 2029 if (std::isnan(value)) value = canonical_not_the_hole_nan_as_double();
2030 WRITE_DOUBLE_FIELD(this, offset, value); 2030 WRITE_DOUBLE_FIELD(this, offset, value);
2031 } 2031 }
2032 2032
2033 2033
2034 void FixedDoubleArray::set_the_hole(int index) { 2034 void FixedDoubleArray::set_the_hole(int index) {
2035 ASSERT(map() != HEAP->fixed_cow_array_map() && 2035 ASSERT(map() != GetHeap()->fixed_cow_array_map() &&
2036 map() != HEAP->fixed_array_map()); 2036 map() != GetHeap()->fixed_array_map());
2037 int offset = kHeaderSize + index * kDoubleSize; 2037 int offset = kHeaderSize + index * kDoubleSize;
2038 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); 2038 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
2039 } 2039 }
2040 2040
2041 2041
2042 bool FixedDoubleArray::is_the_hole(int index) { 2042 bool FixedDoubleArray::is_the_hole(int index) {
2043 int offset = kHeaderSize + index * kDoubleSize; 2043 int offset = kHeaderSize + index * kDoubleSize;
2044 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); 2044 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
2045 } 2045 }
2046 2046
2047 2047
2048 WriteBarrierMode HeapObject::GetWriteBarrierMode( 2048 WriteBarrierMode HeapObject::GetWriteBarrierMode(
2049 const DisallowHeapAllocation& promise) { 2049 const DisallowHeapAllocation& promise) {
2050 Heap* heap = GetHeap(); 2050 Heap* heap = GetHeap();
2051 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; 2051 if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER;
2052 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER; 2052 if (heap->InNewSpace(this)) return SKIP_WRITE_BARRIER;
2053 return UPDATE_WRITE_BARRIER; 2053 return UPDATE_WRITE_BARRIER;
2054 } 2054 }
2055 2055
2056 2056
2057 void FixedArray::set(int index, 2057 void FixedArray::set(int index,
2058 Object* value, 2058 Object* value,
2059 WriteBarrierMode mode) { 2059 WriteBarrierMode mode) {
2060 ASSERT(map() != HEAP->fixed_cow_array_map()); 2060 ASSERT(map() != GetHeap()->fixed_cow_array_map());
2061 ASSERT(index >= 0 && index < this->length()); 2061 ASSERT(index >= 0 && index < this->length());
2062 int offset = kHeaderSize + index * kPointerSize; 2062 int offset = kHeaderSize + index * kPointerSize;
2063 WRITE_FIELD(this, offset, value); 2063 WRITE_FIELD(this, offset, value);
2064 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); 2064 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode);
2065 } 2065 }
2066 2066
2067 2067
2068 void FixedArray::NoIncrementalWriteBarrierSet(FixedArray* array, 2068 void FixedArray::NoIncrementalWriteBarrierSet(FixedArray* array,
2069 int index, 2069 int index,
2070 Object* value) { 2070 Object* value) {
2071 ASSERT(array->map() != HEAP->fixed_cow_array_map()); 2071 ASSERT(array->map() != array->GetHeap()->fixed_cow_array_map());
2072 ASSERT(index >= 0 && index < array->length()); 2072 ASSERT(index >= 0 && index < array->length());
2073 int offset = kHeaderSize + index * kPointerSize; 2073 int offset = kHeaderSize + index * kPointerSize;
2074 WRITE_FIELD(array, offset, value); 2074 WRITE_FIELD(array, offset, value);
2075 Heap* heap = array->GetHeap(); 2075 Heap* heap = array->GetHeap();
2076 if (heap->InNewSpace(value)) { 2076 if (heap->InNewSpace(value)) {
2077 heap->RecordWrite(array->address(), offset); 2077 heap->RecordWrite(array->address(), offset);
2078 } 2078 }
2079 } 2079 }
2080 2080
2081 2081
2082 void FixedArray::NoWriteBarrierSet(FixedArray* array, 2082 void FixedArray::NoWriteBarrierSet(FixedArray* array,
2083 int index, 2083 int index,
2084 Object* value) { 2084 Object* value) {
2085 ASSERT(array->map() != HEAP->fixed_cow_array_map()); 2085 ASSERT(array->map() != array->GetHeap()->fixed_cow_array_map());
2086 ASSERT(index >= 0 && index < array->length()); 2086 ASSERT(index >= 0 && index < array->length());
2087 ASSERT(!HEAP->InNewSpace(value)); 2087 ASSERT(!array->GetHeap()->InNewSpace(value));
2088 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); 2088 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value);
2089 } 2089 }
2090 2090
2091 2091
2092 void FixedArray::set_undefined(int index) { 2092 void FixedArray::set_undefined(int index) {
2093 ASSERT(map() != GetHeap()->fixed_cow_array_map()); 2093 ASSERT(map() != GetHeap()->fixed_cow_array_map());
2094 ASSERT(index >= 0 && index < this->length()); 2094 ASSERT(index >= 0 && index < this->length());
2095 ASSERT(!GetHeap()->InNewSpace(GetHeap()->undefined_value())); 2095 ASSERT(!GetHeap()->InNewSpace(GetHeap()->undefined_value()));
2096 WRITE_FIELD(this, 2096 WRITE_FIELD(this,
2097 kHeaderSize + index * kPointerSize, 2097 kHeaderSize + index * kPointerSize,
2098 GetHeap()->undefined_value()); 2098 GetHeap()->undefined_value());
2099 } 2099 }
2100 2100
2101 2101
2102 void FixedArray::set_null(int index) { 2102 void FixedArray::set_null(int index) {
2103 ASSERT(index >= 0 && index < this->length()); 2103 ASSERT(index >= 0 && index < this->length());
2104 ASSERT(!GetHeap()->InNewSpace(GetHeap()->null_value())); 2104 ASSERT(!GetHeap()->InNewSpace(GetHeap()->null_value()));
2105 WRITE_FIELD(this, 2105 WRITE_FIELD(this,
2106 kHeaderSize + index * kPointerSize, 2106 kHeaderSize + index * kPointerSize,
2107 GetHeap()->null_value()); 2107 GetHeap()->null_value());
2108 } 2108 }
2109 2109
2110 2110
2111 void FixedArray::set_the_hole(int index) { 2111 void FixedArray::set_the_hole(int index) {
2112 ASSERT(map() != HEAP->fixed_cow_array_map()); 2112 ASSERT(map() != GetHeap()->fixed_cow_array_map());
2113 ASSERT(index >= 0 && index < this->length()); 2113 ASSERT(index >= 0 && index < this->length());
2114 ASSERT(!HEAP->InNewSpace(HEAP->the_hole_value())); 2114 ASSERT(!GetHeap()->InNewSpace(GetHeap()->the_hole_value()));
2115 WRITE_FIELD(this, 2115 WRITE_FIELD(this,
2116 kHeaderSize + index * kPointerSize, 2116 kHeaderSize + index * kPointerSize,
2117 GetHeap()->the_hole_value()); 2117 GetHeap()->the_hole_value());
2118 } 2118 }
2119 2119
2120 2120
2121 double* FixedDoubleArray::data_start() { 2121 double* FixedDoubleArray::data_start() {
2122 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize)); 2122 return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize));
2123 } 2123 }
2124 2124
2125 2125
2126 Object** FixedArray::data_start() { 2126 Object** FixedArray::data_start() {
2127 return HeapObject::RawField(this, kHeaderSize); 2127 return HeapObject::RawField(this, kHeaderSize);
2128 } 2128 }
2129 2129
2130 2130
2131 bool DescriptorArray::IsEmpty() { 2131 bool DescriptorArray::IsEmpty() {
2132 ASSERT(length() >= kFirstIndex || 2132 ASSERT(length() >= kFirstIndex ||
2133 this == HEAP->empty_descriptor_array()); 2133 this == GetHeap()->empty_descriptor_array());
2134 return length() < kFirstIndex; 2134 return length() < kFirstIndex;
2135 } 2135 }
2136 2136
2137 2137
2138 void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) { 2138 void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) {
2139 WRITE_FIELD( 2139 WRITE_FIELD(
2140 this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors)); 2140 this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors));
2141 } 2141 }
2142 2142
2143 2143
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after
4988 } 4988 }
4989 4989
4990 4990
4991 Code* JSFunction::code() { 4991 Code* JSFunction::code() {
4992 return Code::cast( 4992 return Code::cast(
4993 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset))); 4993 Code::GetObjectFromEntryAddress(FIELD_ADDR(this, kCodeEntryOffset)));
4994 } 4994 }
4995 4995
4996 4996
4997 void JSFunction::set_code(Code* value) { 4997 void JSFunction::set_code(Code* value) {
4998 ASSERT(!HEAP->InNewSpace(value)); 4998 ASSERT(!GetHeap()->InNewSpace(value));
4999 Address entry = value->entry(); 4999 Address entry = value->entry();
5000 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); 5000 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
5001 GetHeap()->incremental_marking()->RecordWriteOfCodeEntry( 5001 GetHeap()->incremental_marking()->RecordWriteOfCodeEntry(
5002 this, 5002 this,
5003 HeapObject::RawField(this, kCodeEntryOffset), 5003 HeapObject::RawField(this, kCodeEntryOffset),
5004 value); 5004 value);
5005 } 5005 }
5006 5006
5007 5007
5008 void JSFunction::set_code_no_write_barrier(Code* value) { 5008 void JSFunction::set_code_no_write_barrier(Code* value) {
5009 ASSERT(!HEAP->InNewSpace(value)); 5009 ASSERT(!GetHeap()->InNewSpace(value));
5010 Address entry = value->entry(); 5010 Address entry = value->entry();
5011 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry)); 5011 WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
5012 } 5012 }
5013 5013
5014 5014
5015 void JSFunction::ReplaceCode(Code* code) { 5015 void JSFunction::ReplaceCode(Code* code) {
5016 bool was_optimized = IsOptimized(); 5016 bool was_optimized = IsOptimized();
5017 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION; 5017 bool is_optimized = code->kind() == Code::OPTIMIZED_FUNCTION;
5018 5018
5019 set_code(code); 5019 set_code(code);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
5149 Code* JSBuiltinsObject::javascript_builtin_code(Builtins::JavaScript id) { 5149 Code* JSBuiltinsObject::javascript_builtin_code(Builtins::JavaScript id) {
5150 ASSERT(id < kJSBuiltinsCount); // id is unsigned. 5150 ASSERT(id < kJSBuiltinsCount); // id is unsigned.
5151 return Code::cast(READ_FIELD(this, OffsetOfCodeWithId(id))); 5151 return Code::cast(READ_FIELD(this, OffsetOfCodeWithId(id)));
5152 } 5152 }
5153 5153
5154 5154
5155 void JSBuiltinsObject::set_javascript_builtin_code(Builtins::JavaScript id, 5155 void JSBuiltinsObject::set_javascript_builtin_code(Builtins::JavaScript id,
5156 Code* value) { 5156 Code* value) {
5157 ASSERT(id < kJSBuiltinsCount); // id is unsigned. 5157 ASSERT(id < kJSBuiltinsCount); // id is unsigned.
5158 WRITE_FIELD(this, OffsetOfCodeWithId(id), value); 5158 WRITE_FIELD(this, OffsetOfCodeWithId(id), value);
5159 ASSERT(!HEAP->InNewSpace(value)); 5159 ASSERT(!GetHeap()->InNewSpace(value));
5160 } 5160 }
5161 5161
5162 5162
5163 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) 5163 ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
5164 ACCESSORS(JSProxy, hash, Object, kHashOffset) 5164 ACCESSORS(JSProxy, hash, Object, kHashOffset)
5165 ACCESSORS(JSFunctionProxy, call_trap, Object, kCallTrapOffset) 5165 ACCESSORS(JSFunctionProxy, call_trap, Object, kCallTrapOffset)
5166 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset) 5166 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset)
5167 5167
5168 5168
5169 void JSProxy::InitializeBody(int object_size, Object* value) { 5169 void JSProxy::InitializeBody(int object_size, Object* value) {
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
6299 #undef WRITE_UINT32_FIELD 6299 #undef WRITE_UINT32_FIELD
6300 #undef READ_SHORT_FIELD 6300 #undef READ_SHORT_FIELD
6301 #undef WRITE_SHORT_FIELD 6301 #undef WRITE_SHORT_FIELD
6302 #undef READ_BYTE_FIELD 6302 #undef READ_BYTE_FIELD
6303 #undef WRITE_BYTE_FIELD 6303 #undef WRITE_BYTE_FIELD
6304 6304
6305 6305
6306 } } // namespace v8::internal 6306 } } // namespace v8::internal
6307 6307
6308 #endif // V8_OBJECTS_INL_H_ 6308 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698