OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (!that->IsString()) return false; | 113 if (!that->IsString()) return false; |
114 return String::cast(this)->Equals(String::cast(that)); | 114 return String::cast(this)->Equals(String::cast(that)); |
115 } else if (this->IsSimd128Value()) { | 115 } else if (this->IsSimd128Value()) { |
116 if (!that->IsSimd128Value()) return false; | 116 if (!that->IsSimd128Value()) return false; |
117 return Simd128Value::cast(this)->Equals(Simd128Value::cast(that)); | 117 return Simd128Value::cast(this)->Equals(Simd128Value::cast(that)); |
118 } | 118 } |
119 return this == that; | 119 return this == that; |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 bool Object::IsCallable() const { | 123 // static |
124 const Object* fun = this; | 124 Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) { |
125 while (fun->IsJSFunctionProxy()) { | 125 if (object->IsNumber()) return isolate->factory()->number_string(); |
126 fun = JSFunctionProxy::cast(fun)->call_trap(); | 126 if (object->IsUndefined() || object->IsUndetectableObject()) { |
| 127 return isolate->factory()->undefined_string(); |
127 } | 128 } |
128 return fun->IsJSFunction() || | 129 if (object->IsBoolean()) return isolate->factory()->boolean_string(); |
129 (fun->IsHeapObject() && | 130 if (object->IsSymbol()) return isolate->factory()->symbol_string(); |
130 HeapObject::cast(fun)->map()->has_instance_call_handler()); | 131 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ |
| 132 if (object->Is##Type()) return isolate->factory()->type##_string(); |
| 133 SIMD128_TYPES(SIMD128_TYPE) |
| 134 #undef SIMD128_TYPE |
| 135 if (object->IsCallable()) return isolate->factory()->function_string(); |
| 136 return isolate->factory()->object_string(); |
131 } | 137 } |
132 | 138 |
133 | 139 |
134 bool Object::IsPromise(Handle<Object> object) { | 140 bool Object::IsPromise(Handle<Object> object) { |
135 if (!object->IsJSObject()) return false; | 141 if (!object->IsJSObject()) return false; |
136 auto js_object = Handle<JSObject>::cast(object); | 142 auto js_object = Handle<JSObject>::cast(object); |
137 // Promises can't have access checks. | 143 // Promises can't have access checks. |
138 if (js_object->map()->is_access_check_needed()) return false; | 144 if (js_object->map()->is_access_check_needed()) return false; |
139 auto isolate = js_object->GetIsolate(); | 145 auto isolate = js_object->GetIsolate(); |
140 // TODO(dcarney): this should just be read from the symbol registry so as not | 146 // TODO(dcarney): this should just be read from the symbol registry so as not |
(...skipping 9062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9203 | 9209 |
9204 // XOR-ing the prototype and constructor directly yields too many zero bits | 9210 // XOR-ing the prototype and constructor directly yields too many zero bits |
9205 // when the two pointers are close (which is fairly common). | 9211 // when the two pointers are close (which is fairly common). |
9206 // To avoid this we shift the prototype bits relatively to the constructor. | 9212 // To avoid this we shift the prototype bits relatively to the constructor. |
9207 hash ^= ObjectAddressForHashing(prototype()) << (32 - kPageSizeBits); | 9213 hash ^= ObjectAddressForHashing(prototype()) << (32 - kPageSizeBits); |
9208 | 9214 |
9209 return hash ^ (hash >> 16) ^ bit_field2(); | 9215 return hash ^ (hash >> 16) ^ bit_field2(); |
9210 } | 9216 } |
9211 | 9217 |
9212 | 9218 |
9213 static bool CheckEquivalent(Map* first, Map* second) { | 9219 namespace { |
| 9220 |
| 9221 bool CheckEquivalent(Map* first, Map* second) { |
9214 return first->GetConstructor() == second->GetConstructor() && | 9222 return first->GetConstructor() == second->GetConstructor() && |
9215 first->prototype() == second->prototype() && | 9223 first->prototype() == second->prototype() && |
9216 first->instance_type() == second->instance_type() && | 9224 first->instance_type() == second->instance_type() && |
9217 first->bit_field() == second->bit_field() && | 9225 first->bit_field() == second->bit_field() && |
9218 first->is_extensible() == second->is_extensible() && | 9226 first->is_extensible() == second->is_extensible() && |
9219 first->is_strong() == second->is_strong() && | 9227 first->is_strong() == second->is_strong() && |
9220 first->has_instance_call_handler() == | 9228 first->is_hidden_prototype() == second->is_hidden_prototype(); |
9221 second->has_instance_call_handler(); | |
9222 } | 9229 } |
9223 | 9230 |
| 9231 } // namespace |
| 9232 |
9224 | 9233 |
9225 bool Map::EquivalentToForTransition(Map* other) { | 9234 bool Map::EquivalentToForTransition(Map* other) { |
9226 return CheckEquivalent(this, other); | 9235 return CheckEquivalent(this, other); |
9227 } | 9236 } |
9228 | 9237 |
9229 | 9238 |
9230 bool Map::EquivalentToForNormalization(Map* other, | 9239 bool Map::EquivalentToForNormalization(Map* other, |
9231 PropertyNormalizationMode mode) { | 9240 PropertyNormalizationMode mode) { |
9232 int properties = | 9241 int properties = |
9233 mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties(); | 9242 mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties(); |
(...skipping 6589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15823 if (cell->value() != *new_value) { | 15832 if (cell->value() != *new_value) { |
15824 cell->set_value(*new_value); | 15833 cell->set_value(*new_value); |
15825 Isolate* isolate = cell->GetIsolate(); | 15834 Isolate* isolate = cell->GetIsolate(); |
15826 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15835 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
15827 isolate, DependentCode::kPropertyCellChangedGroup); | 15836 isolate, DependentCode::kPropertyCellChangedGroup); |
15828 } | 15837 } |
15829 } | 15838 } |
15830 | 15839 |
15831 } // namespace internal | 15840 } // namespace internal |
15832 } // namespace v8 | 15841 } // namespace v8 |
OLD | NEW |