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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (!that->IsString()) return false; | 169 if (!that->IsString()) return false; |
170 return String::cast(this)->Equals(String::cast(that)); | 170 return String::cast(this)->Equals(String::cast(that)); |
171 } else if (this->IsSimd128Value()) { | 171 } else if (this->IsSimd128Value()) { |
172 if (!that->IsSimd128Value()) return false; | 172 if (!that->IsSimd128Value()) return false; |
173 return Simd128Value::cast(this)->Equals(Simd128Value::cast(that)); | 173 return Simd128Value::cast(this)->Equals(Simd128Value::cast(that)); |
174 } | 174 } |
175 return this == that; | 175 return this == that; |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 bool Object::IsCallable() const { | 179 // static |
180 const Object* fun = this; | 180 Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) { |
181 while (fun->IsJSFunctionProxy()) { | 181 if (object->IsNumber()) return isolate->factory()->number_string(); |
182 fun = JSFunctionProxy::cast(fun)->call_trap(); | 182 if (object->IsUndefined() || object->IsUndetectableObject()) { |
| 183 return isolate->factory()->undefined_string(); |
183 } | 184 } |
184 return fun->IsJSFunction() || | 185 if (object->IsBoolean()) return isolate->factory()->boolean_string(); |
185 (fun->IsHeapObject() && | 186 if (object->IsSymbol()) return isolate->factory()->symbol_string(); |
186 HeapObject::cast(fun)->map()->has_instance_call_handler()); | 187 #define SIMD128_TYPE(TYPE, Type, type, lane_count, lane_type) \ |
| 188 if (object->Is##Type()) return isolate->factory()->type##_string(); |
| 189 SIMD128_TYPES(SIMD128_TYPE) |
| 190 #undef SIMD128_TYPE |
| 191 if (object->IsCallable()) return isolate->factory()->function_string(); |
| 192 return isolate->factory()->object_string(); |
187 } | 193 } |
188 | 194 |
189 | 195 |
190 bool Object::IsPromise(Handle<Object> object) { | 196 bool Object::IsPromise(Handle<Object> object) { |
191 if (!object->IsJSObject()) return false; | 197 if (!object->IsJSObject()) return false; |
192 auto js_object = Handle<JSObject>::cast(object); | 198 auto js_object = Handle<JSObject>::cast(object); |
193 // Promises can't have access checks. | 199 // Promises can't have access checks. |
194 if (js_object->map()->is_access_check_needed()) return false; | 200 if (js_object->map()->is_access_check_needed()) return false; |
195 auto isolate = js_object->GetIsolate(); | 201 auto isolate = js_object->GetIsolate(); |
196 // TODO(dcarney): this should just be read from the symbol registry so as not | 202 // TODO(dcarney): this should just be read from the symbol registry so as not |
(...skipping 9323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9520 | 9526 |
9521 // XOR-ing the prototype and constructor directly yields too many zero bits | 9527 // XOR-ing the prototype and constructor directly yields too many zero bits |
9522 // when the two pointers are close (which is fairly common). | 9528 // when the two pointers are close (which is fairly common). |
9523 // To avoid this we shift the prototype bits relatively to the constructor. | 9529 // To avoid this we shift the prototype bits relatively to the constructor. |
9524 hash ^= ObjectAddressForHashing(prototype()) << (32 - kPageSizeBits); | 9530 hash ^= ObjectAddressForHashing(prototype()) << (32 - kPageSizeBits); |
9525 | 9531 |
9526 return hash ^ (hash >> 16) ^ bit_field2(); | 9532 return hash ^ (hash >> 16) ^ bit_field2(); |
9527 } | 9533 } |
9528 | 9534 |
9529 | 9535 |
9530 static bool CheckEquivalent(Map* first, Map* second) { | 9536 namespace { |
| 9537 |
| 9538 bool CheckEquivalent(Map* first, Map* second) { |
9531 return first->GetConstructor() == second->GetConstructor() && | 9539 return first->GetConstructor() == second->GetConstructor() && |
9532 first->prototype() == second->prototype() && | 9540 first->prototype() == second->prototype() && |
9533 first->instance_type() == second->instance_type() && | 9541 first->instance_type() == second->instance_type() && |
9534 first->bit_field() == second->bit_field() && | 9542 first->bit_field() == second->bit_field() && |
9535 first->is_extensible() == second->is_extensible() && | 9543 first->is_extensible() == second->is_extensible() && |
9536 first->is_strong() == second->is_strong() && | 9544 first->is_strong() == second->is_strong() && |
9537 first->has_instance_call_handler() == | 9545 first->is_hidden_prototype() == second->is_hidden_prototype(); |
9538 second->has_instance_call_handler(); | |
9539 } | 9546 } |
9540 | 9547 |
| 9548 } // namespace |
| 9549 |
9541 | 9550 |
9542 bool Map::EquivalentToForTransition(Map* other) { | 9551 bool Map::EquivalentToForTransition(Map* other) { |
9543 return CheckEquivalent(this, other); | 9552 return CheckEquivalent(this, other); |
9544 } | 9553 } |
9545 | 9554 |
9546 | 9555 |
9547 bool Map::EquivalentToForNormalization(Map* other, | 9556 bool Map::EquivalentToForNormalization(Map* other, |
9548 PropertyNormalizationMode mode) { | 9557 PropertyNormalizationMode mode) { |
9549 int properties = | 9558 int properties = |
9550 mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties(); | 9559 mode == CLEAR_INOBJECT_PROPERTIES ? 0 : other->GetInObjectProperties(); |
(...skipping 6608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16159 if (cell->value() != *new_value) { | 16168 if (cell->value() != *new_value) { |
16160 cell->set_value(*new_value); | 16169 cell->set_value(*new_value); |
16161 Isolate* isolate = cell->GetIsolate(); | 16170 Isolate* isolate = cell->GetIsolate(); |
16162 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16171 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16163 isolate, DependentCode::kPropertyCellChangedGroup); | 16172 isolate, DependentCode::kPropertyCellChangedGroup); |
16164 } | 16173 } |
16165 } | 16174 } |
16166 | 16175 |
16167 } // namespace internal | 16176 } // namespace internal |
16168 } // namespace v8 | 16177 } // namespace v8 |
OLD | NEW |