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

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

Issue 2060213002: Revert of Replace all remaining Oddball checks with new function (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« 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 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 bool HeapObject::Is##Type() const { return map() == GetHeap()->type##_map(); } 155 bool HeapObject::Is##Type() const { return map() == GetHeap()->type##_map(); }
156 SIMD128_TYPES(SIMD128_TYPE_CHECKER) 156 SIMD128_TYPES(SIMD128_TYPE_CHECKER)
157 #undef SIMD128_TYPE_CHECKER 157 #undef SIMD128_TYPE_CHECKER
158 158
159 // TODO(cbruni): remove once all the isolate-based versions are in place. 159 // TODO(cbruni): remove once all the isolate-based versions are in place.
160 #define IS_TYPE_FUNCTION_DEF(type_) \ 160 #define IS_TYPE_FUNCTION_DEF(type_) \
161 bool Object::Is##type_() const { \ 161 bool Object::Is##type_() const { \
162 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \ 162 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \
163 } 163 }
164 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF) 164 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF)
165 #undef IS_TYPE_FUNCTION_DEF
166
167 #define IS_TYPE_FUNCTION_DEF(Type, Value) \
168 bool Object::Is##Type(Isolate* isolate) const { \
169 return this == isolate->heap()->Value(); \
170 } \
171 bool HeapObject::Is##Type(Isolate* isolate) const { \
172 return this == isolate->heap()->Value(); \
173 }
174 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF) 165 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF)
175 #undef IS_TYPE_FUNCTION_DEF 166 #undef IS_TYPE_FUNCTION_DEF
176 167
168 bool HeapObject::IsTheHole(Isolate* isolate) const {
169 return this == isolate->heap()->the_hole_value();
170 }
171
172 bool HeapObject::IsUndefined(Isolate* isolate) const {
173 return this == isolate->heap()->undefined_value();
174 }
175
176 bool Object::IsTheHole(Isolate* isolate) const {
177 return this == isolate->heap()->the_hole_value();
178 }
179
180 bool Object::IsUndefined(Isolate* isolate) const {
181 return this == isolate->heap()->undefined_value();
182 }
183
177 bool HeapObject::IsString() const { 184 bool HeapObject::IsString() const {
178 return map()->instance_type() < FIRST_NONSTRING_TYPE; 185 return map()->instance_type() < FIRST_NONSTRING_TYPE;
179 } 186 }
180 187
181 bool HeapObject::IsName() const { 188 bool HeapObject::IsName() const {
182 return map()->instance_type() <= LAST_NAME_TYPE; 189 return map()->instance_type() <= LAST_NAME_TYPE;
183 } 190 }
184 191
185 bool HeapObject::IsUniqueName() const { 192 bool HeapObject::IsUniqueName() const {
186 return IsInternalizedString() || IsSymbol(); 193 return IsInternalizedString() || IsSymbol();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } else { 294 } else {
288 if (filter & SKIP_STRINGS) return true; 295 if (filter & SKIP_STRINGS) return true;
289 } 296 }
290 return false; 297 return false;
291 } 298 }
292 299
293 300
294 Handle<Object> Object::NewStorageFor(Isolate* isolate, 301 Handle<Object> Object::NewStorageFor(Isolate* isolate,
295 Handle<Object> object, 302 Handle<Object> object,
296 Representation representation) { 303 Representation representation) {
297 if (representation.IsSmi() && object->IsUninitialized(isolate)) { 304 if (representation.IsSmi() && object->IsUninitialized()) {
298 return handle(Smi::FromInt(0), isolate); 305 return handle(Smi::FromInt(0), isolate);
299 } 306 }
300 if (!representation.IsDouble()) return object; 307 if (!representation.IsDouble()) return object;
301 double value; 308 double value;
302 if (object->IsUninitialized(isolate)) { 309 if (object->IsUninitialized()) {
303 value = 0; 310 value = 0;
304 } else if (object->IsMutableHeapNumber()) { 311 } else if (object->IsMutableHeapNumber()) {
305 value = HeapNumber::cast(*object)->value(); 312 value = HeapNumber::cast(*object)->value();
306 } else { 313 } else {
307 value = object->Number(); 314 value = object->Number();
308 } 315 }
309 return isolate->factory()->NewHeapNumber(value, MUTABLE); 316 return isolate->factory()->NewHeapNumber(value, MUTABLE);
310 } 317 }
311 318
312 319
313 Handle<Object> Object::WrapForRead(Isolate* isolate, 320 Handle<Object> Object::WrapForRead(Isolate* isolate,
314 Handle<Object> object, 321 Handle<Object> object,
315 Representation representation) { 322 Representation representation) {
316 DCHECK(!object->IsUninitialized(isolate)); 323 DCHECK(!object->IsUninitialized());
317 if (!representation.IsDouble()) { 324 if (!representation.IsDouble()) {
318 DCHECK(object->FitsRepresentation(representation)); 325 DCHECK(object->FitsRepresentation(representation));
319 return object; 326 return object;
320 } 327 }
321 return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value()); 328 return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value());
322 } 329 }
323 330
324 331
325 StringShape::StringShape(const String* str) 332 StringShape::StringShape(const String* str)
326 : type_(str->map()->instance_type()) { 333 : type_(str->map()->instance_type()) {
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 #define MAKE_STRUCT_PREDICATE(NAME, Name, name) \ 948 #define MAKE_STRUCT_PREDICATE(NAME, Name, name) \
942 bool Object::Is##Name() const { \ 949 bool Object::Is##Name() const { \
943 return IsHeapObject() && HeapObject::cast(this)->Is##Name(); \ 950 return IsHeapObject() && HeapObject::cast(this)->Is##Name(); \
944 } \ 951 } \
945 bool HeapObject::Is##Name() const { \ 952 bool HeapObject::Is##Name() const { \
946 return map()->instance_type() == NAME##_TYPE; \ 953 return map()->instance_type() == NAME##_TYPE; \
947 } 954 }
948 STRUCT_LIST(MAKE_STRUCT_PREDICATE) 955 STRUCT_LIST(MAKE_STRUCT_PREDICATE)
949 #undef MAKE_STRUCT_PREDICATE 956 #undef MAKE_STRUCT_PREDICATE
950 957
958 #define MAKE_ODDBALL_PREDICATE(Name) \
959 bool HeapObject::Is##Name() const { \
960 return IsOddball() && Oddball::cast(this)->kind() == Oddball::k##Name; \
961 }
962 ODDBALL_LIST(MAKE_ODDBALL_PREDICATE)
963
964 #undef MAKE_ODDBALL_PREDICATE
951 double Object::Number() const { 965 double Object::Number() const {
952 DCHECK(IsNumber()); 966 DCHECK(IsNumber());
953 return IsSmi() 967 return IsSmi()
954 ? static_cast<double>(reinterpret_cast<const Smi*>(this)->value()) 968 ? static_cast<double>(reinterpret_cast<const Smi*>(this)->value())
955 : reinterpret_cast<const HeapNumber*>(this)->value(); 969 : reinterpret_cast<const HeapNumber*>(this)->value();
956 } 970 }
957 971
958 972
959 bool Object::IsNaN() const { 973 bool Object::IsNaN() const {
960 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); 974 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value());
961 } 975 }
962 976
963 977
964 bool Object::IsMinusZero() const { 978 bool Object::IsMinusZero() const {
965 return this->IsHeapNumber() && 979 return this->IsHeapNumber() &&
966 i::IsMinusZero(HeapNumber::cast(this)->value()); 980 i::IsMinusZero(HeapNumber::cast(this)->value());
967 } 981 }
968 982
969 983
970 Representation Object::OptimalRepresentation() { 984 Representation Object::OptimalRepresentation() {
971 if (!FLAG_track_fields) return Representation::Tagged(); 985 if (!FLAG_track_fields) return Representation::Tagged();
972 if (IsSmi()) { 986 if (IsSmi()) {
973 return Representation::Smi(); 987 return Representation::Smi();
974 } else if (FLAG_track_double_fields && IsHeapNumber()) { 988 } else if (FLAG_track_double_fields && IsHeapNumber()) {
975 return Representation::Double(); 989 return Representation::Double();
976 } else if (FLAG_track_computed_fields && 990 } else if (FLAG_track_computed_fields && IsUninitialized()) {
977 IsUninitialized(HeapObject::cast(this)->GetIsolate())) {
978 return Representation::None(); 991 return Representation::None();
979 } else if (FLAG_track_heap_object_fields) { 992 } else if (FLAG_track_heap_object_fields) {
980 DCHECK(IsHeapObject()); 993 DCHECK(IsHeapObject());
981 return Representation::HeapObject(); 994 return Representation::HeapObject();
982 } else { 995 } else {
983 return Representation::Tagged(); 996 return Representation::Tagged();
984 } 997 }
985 } 998 }
986 999
987 1000
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2181 } 2194 }
2182 } 2195 }
2183 2196
2184 void JSObject::WriteToField(int descriptor, PropertyDetails details, 2197 void JSObject::WriteToField(int descriptor, PropertyDetails details,
2185 Object* value) { 2198 Object* value) {
2186 DCHECK(details.type() == DATA); 2199 DCHECK(details.type() == DATA);
2187 DisallowHeapAllocation no_gc; 2200 DisallowHeapAllocation no_gc;
2188 FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor); 2201 FieldIndex index = FieldIndex::ForDescriptor(map(), descriptor);
2189 if (details.representation().IsDouble()) { 2202 if (details.representation().IsDouble()) {
2190 // Nothing more to be done. 2203 // Nothing more to be done.
2191 if (value->IsUninitialized(this->GetIsolate())) { 2204 if (value->IsUninitialized()) return;
2192 return;
2193 }
2194 if (IsUnboxedDoubleField(index)) { 2205 if (IsUnboxedDoubleField(index)) {
2195 RawFastDoublePropertyAtPut(index, value->Number()); 2206 RawFastDoublePropertyAtPut(index, value->Number());
2196 } else { 2207 } else {
2197 HeapNumber* box = HeapNumber::cast(RawFastPropertyAt(index)); 2208 HeapNumber* box = HeapNumber::cast(RawFastPropertyAt(index));
2198 DCHECK(box->IsMutableHeapNumber()); 2209 DCHECK(box->IsMutableHeapNumber());
2199 box->set_value(value->Number()); 2210 box->set_value(value->Number());
2200 } 2211 }
2201 } else { 2212 } else {
2202 RawFastPropertyAtPut(index, value); 2213 RawFastPropertyAtPut(index, value);
2203 } 2214 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 return Object::ToUint32(index) && *index != kMaxUInt32; 2291 return Object::ToUint32(index) && *index != kMaxUInt32;
2281 } 2292 }
2282 2293
2283 2294
2284 void Object::VerifyApiCallResultType() { 2295 void Object::VerifyApiCallResultType() {
2285 #if DEBUG 2296 #if DEBUG
2286 if (IsSmi()) return; 2297 if (IsSmi()) return;
2287 DCHECK(IsHeapObject()); 2298 DCHECK(IsHeapObject());
2288 Isolate* isolate = HeapObject::cast(this)->GetIsolate(); 2299 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
2289 if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() || 2300 if (!(IsString() || IsSymbol() || IsJSReceiver() || IsHeapNumber() ||
2290 IsSimd128Value() || IsUndefined(isolate) || IsTrue(isolate) || 2301 IsSimd128Value() || IsUndefined(isolate) || IsTrue() || IsFalse() ||
2291 IsFalse(isolate) || IsNull(isolate))) { 2302 IsNull())) {
2292 FATAL("API call returned invalid object"); 2303 FATAL("API call returned invalid object");
2293 } 2304 }
2294 #endif // DEBUG 2305 #endif // DEBUG
2295 } 2306 }
2296 2307
2297 2308
2298 Object* FixedArray::get(int index) const { 2309 Object* FixedArray::get(int index) const {
2299 SLOW_DCHECK(index >= 0 && index < this->length()); 2310 SLOW_DCHECK(index >= 0 && index < this->length());
2300 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 2311 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
2301 } 2312 }
(...skipping 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after
5276 BytecodeArray* AbstractCode::GetBytecodeArray() { 5287 BytecodeArray* AbstractCode::GetBytecodeArray() {
5277 return BytecodeArray::cast(this); 5288 return BytecodeArray::cast(this);
5278 } 5289 }
5279 5290
5280 Object* Map::prototype() const { 5291 Object* Map::prototype() const {
5281 return READ_FIELD(this, kPrototypeOffset); 5292 return READ_FIELD(this, kPrototypeOffset);
5282 } 5293 }
5283 5294
5284 5295
5285 void Map::set_prototype(Object* value, WriteBarrierMode mode) { 5296 void Map::set_prototype(Object* value, WriteBarrierMode mode) {
5286 DCHECK(value->IsNull(GetIsolate()) || value->IsJSReceiver()); 5297 DCHECK(value->IsNull() || value->IsJSReceiver());
5287 WRITE_FIELD(this, kPrototypeOffset, value); 5298 WRITE_FIELD(this, kPrototypeOffset, value);
5288 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode); 5299 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value, mode);
5289 } 5300 }
5290 5301
5291 5302
5292 LayoutDescriptor* Map::layout_descriptor_gc_safe() { 5303 LayoutDescriptor* Map::layout_descriptor_gc_safe() {
5293 Object* layout_desc = READ_FIELD(this, kLayoutDecriptorOffset); 5304 Object* layout_desc = READ_FIELD(this, kLayoutDecriptorOffset);
5294 return LayoutDescriptor::cast_gc_safe(layout_desc); 5305 return LayoutDescriptor::cast_gc_safe(layout_desc);
5295 } 5306 }
5296 5307
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
7305 void AccessorPair::set(AccessorComponent component, Object* value) { 7316 void AccessorPair::set(AccessorComponent component, Object* value) {
7306 if (component == ACCESSOR_GETTER) { 7317 if (component == ACCESSOR_GETTER) {
7307 set_getter(value); 7318 set_getter(value);
7308 } else { 7319 } else {
7309 set_setter(value); 7320 set_setter(value);
7310 } 7321 }
7311 } 7322 }
7312 7323
7313 7324
7314 void AccessorPair::SetComponents(Object* getter, Object* setter) { 7325 void AccessorPair::SetComponents(Object* getter, Object* setter) {
7315 Isolate* isolate = GetIsolate(); 7326 if (!getter->IsNull()) set_getter(getter);
7316 if (!getter->IsNull(isolate)) set_getter(getter); 7327 if (!setter->IsNull()) set_setter(setter);
7317 if (!setter->IsNull(isolate)) set_setter(setter);
7318 } 7328 }
7319 7329
7320 7330
7321 bool AccessorPair::Equals(AccessorPair* pair) { 7331 bool AccessorPair::Equals(AccessorPair* pair) {
7322 return (this == pair) || pair->Equals(getter(), setter()); 7332 return (this == pair) || pair->Equals(getter(), setter());
7323 } 7333 }
7324 7334
7325 7335
7326 bool AccessorPair::Equals(Object* getter_value, Object* setter_value) { 7336 bool AccessorPair::Equals(Object* getter_value, Object* setter_value) {
7327 return (getter() == getter_value) && (setter() == setter_value); 7337 return (getter() == getter_value) && (setter() == setter_value);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
7903 #undef WRITE_INT64_FIELD 7913 #undef WRITE_INT64_FIELD
7904 #undef READ_BYTE_FIELD 7914 #undef READ_BYTE_FIELD
7905 #undef WRITE_BYTE_FIELD 7915 #undef WRITE_BYTE_FIELD
7906 #undef NOBARRIER_READ_BYTE_FIELD 7916 #undef NOBARRIER_READ_BYTE_FIELD
7907 #undef NOBARRIER_WRITE_BYTE_FIELD 7917 #undef NOBARRIER_WRITE_BYTE_FIELD
7908 7918
7909 } // namespace internal 7919 } // namespace internal
7910 } // namespace v8 7920 } // namespace v8
7911 7921
7912 #endif // V8_OBJECTS_INL_H_ 7922 #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