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

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

Issue 1427483002: [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
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 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 2118
2119 2119
2120 void WeakCell::clear_next(Heap* heap) { 2120 void WeakCell::clear_next(Heap* heap) {
2121 set_next(heap->the_hole_value(), SKIP_WRITE_BARRIER); 2121 set_next(heap->the_hole_value(), SKIP_WRITE_BARRIER);
2122 } 2122 }
2123 2123
2124 2124
2125 bool WeakCell::next_cleared() { return next()->IsTheHole(); } 2125 bool WeakCell::next_cleared() { return next()->IsTheHole(); }
2126 2126
2127 2127
2128 int JSObject::GetHeaderSize() { 2128 int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); }
2129 InstanceType type = map()->instance_type(); 2129
2130
2131 int JSObject::GetHeaderSize(InstanceType type) {
2130 // Check for the most common kind of JavaScript object before 2132 // Check for the most common kind of JavaScript object before
2131 // falling into the generic switch. This speeds up the internal 2133 // falling into the generic switch. This speeds up the internal
2132 // field operations considerably on average. 2134 // field operations considerably on average.
2133 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; 2135 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
2134 switch (type) { 2136 switch (type) {
2135 case JS_GENERATOR_OBJECT_TYPE: 2137 case JS_GENERATOR_OBJECT_TYPE:
2136 return JSGeneratorObject::kSize; 2138 return JSGeneratorObject::kSize;
2137 case JS_MODULE_TYPE: 2139 case JS_MODULE_TYPE:
2138 return JSModule::kSize; 2140 return JSModule::kSize;
2139 case JS_GLOBAL_PROXY_TYPE: 2141 case JS_GLOBAL_PROXY_TYPE:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 return JSObject::kHeaderSize; 2178 return JSObject::kHeaderSize;
2177 case JS_MESSAGE_OBJECT_TYPE: 2179 case JS_MESSAGE_OBJECT_TYPE:
2178 return JSMessageObject::kSize; 2180 return JSMessageObject::kSize;
2179 default: 2181 default:
2180 UNREACHABLE(); 2182 UNREACHABLE();
2181 return 0; 2183 return 0;
2182 } 2184 }
2183 } 2185 }
2184 2186
2185 2187
2188 int JSObject::GetHeaderWithInternalFieldsSize(InstanceType type) {
2189 // Check for the most common kind of JavaScript object before
2190 // falling into the generic switch. This speeds up the internal
2191 // field operations considerably on average.
2192 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize;
2193 switch (type) {
2194 case JS_GENERATOR_OBJECT_TYPE:
2195 return JSGeneratorObject::kSize;
2196 case JS_MODULE_TYPE:
2197 return JSModule::kSize;
2198 case JS_GLOBAL_PROXY_TYPE:
2199 return JSGlobalProxy::kSize;
2200 case JS_GLOBAL_OBJECT_TYPE:
2201 return JSGlobalObject::kSize;
2202 case JS_BUILTINS_OBJECT_TYPE:
2203 return JSBuiltinsObject::kSize;
2204 case JS_FUNCTION_TYPE:
2205 return JSFunction::kSize;
2206 case JS_VALUE_TYPE:
2207 return JSValue::kSize;
2208 case JS_DATE_TYPE:
2209 return JSDate::kSize;
2210 case JS_ARRAY_TYPE:
2211 return JSArray::kSize;
2212 case JS_ARRAY_BUFFER_TYPE:
2213 return JSArrayBuffer::kSizeWithInternalFields;
2214 case JS_TYPED_ARRAY_TYPE:
2215 return JSTypedArray::kSizeWithInternalFields;
2216 case JS_DATA_VIEW_TYPE:
2217 return JSDataView::kSizeWithInternalFields;
2218 case JS_SET_TYPE:
2219 return JSSet::kSize;
2220 case JS_MAP_TYPE:
2221 return JSMap::kSize;
2222 case JS_SET_ITERATOR_TYPE:
2223 return JSSetIterator::kSize;
2224 case JS_MAP_ITERATOR_TYPE:
2225 return JSMapIterator::kSize;
2226 case JS_ITERATOR_RESULT_TYPE:
2227 return JSIteratorResult::kSize;
2228 case JS_WEAK_MAP_TYPE:
2229 return JSWeakMap::kSize;
2230 case JS_WEAK_SET_TYPE:
2231 return JSWeakSet::kSize;
2232 case JS_REGEXP_TYPE:
2233 return JSRegExp::kSize;
2234 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
2235 return JSObject::kHeaderSize;
2236 case JS_MESSAGE_OBJECT_TYPE:
2237 return JSMessageObject::kSize;
2238 default:
2239 UNREACHABLE();
2240 return 0;
2241 }
2242 }
2243
2244
2186 int JSObject::GetInternalFieldCount() { 2245 int JSObject::GetInternalFieldCount() {
2187 DCHECK(1 << kPointerSizeLog2 == kPointerSize);
2188 // Make sure to adjust for the number of in-object properties. These
2189 // properties do contribute to the size, but are not internal fields.
2190 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - 2246 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) -
2191 map()->GetInObjectProperties(); 2247 map()->GetInObjectProperties();
2192 } 2248 }
2193 2249
2194 2250
2195 int JSObject::GetInternalFieldOffset(int index) { 2251 int JSObject::GetInternalFieldOffset(int index) {
2196 DCHECK(index < GetInternalFieldCount() && index >= 0); 2252 DCHECK(index < GetInternalFieldCount() && index >= 0);
2197 return GetHeaderSize() + (kPointerSize * index); 2253 return GetHeaderSize() + (kPointerSize * index);
2198 } 2254 }
2199 2255
(...skipping 5932 matching lines...) Expand 10 before | Expand all | Expand 10 after
8132 #undef WRITE_INT64_FIELD 8188 #undef WRITE_INT64_FIELD
8133 #undef READ_BYTE_FIELD 8189 #undef READ_BYTE_FIELD
8134 #undef WRITE_BYTE_FIELD 8190 #undef WRITE_BYTE_FIELD
8135 #undef NOBARRIER_READ_BYTE_FIELD 8191 #undef NOBARRIER_READ_BYTE_FIELD
8136 #undef NOBARRIER_WRITE_BYTE_FIELD 8192 #undef NOBARRIER_WRITE_BYTE_FIELD
8137 8193
8138 } // namespace internal 8194 } // namespace internal
8139 } // namespace v8 8195 } // namespace v8
8140 8196
8141 #endif // V8_OBJECTS_INL_H_ 8197 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698