| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 uint32_t hash = Simd128Value::cast(object)->Hash(); | 1970 uint32_t hash = Simd128Value::cast(object)->Hash(); |
| 1971 return Smi::FromInt(hash & Smi::kMaxValue); | 1971 return Smi::FromInt(hash & Smi::kMaxValue); |
| 1972 } | 1972 } |
| 1973 DCHECK(object->IsJSReceiver()); | 1973 DCHECK(object->IsJSReceiver()); |
| 1974 // Simply return the receiver as it is guaranteed to not be a SMI. | 1974 // Simply return the receiver as it is guaranteed to not be a SMI. |
| 1975 return object; | 1975 return object; |
| 1976 } | 1976 } |
| 1977 | 1977 |
| 1978 } // namespace | 1978 } // namespace |
| 1979 | 1979 |
| 1980 Maybe<bool> Object::IsRegExp(Isolate* isolate, Handle<Object> object) { |
| 1981 if (!object->IsJSReceiver()) return Just(false); |
| 1982 |
| 1983 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object); |
| 1984 |
| 1985 if (isolate->regexp_function()->initial_map() == receiver->map()) { |
| 1986 // Fast-path for unmodified JSRegExp instances. |
| 1987 return Just(true); |
| 1988 } |
| 1989 |
| 1990 Handle<Object> match; |
| 1991 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 1992 isolate, match, |
| 1993 JSObject::GetProperty(receiver, isolate->factory()->match_symbol()), |
| 1994 Nothing<bool>()); |
| 1995 |
| 1996 if (!match->IsUndefined(isolate)) return Just(match->BooleanValue()); |
| 1997 return Just(object->IsJSRegExp()); |
| 1998 } |
| 1999 |
| 1980 Object* Object::GetHash() { | 2000 Object* Object::GetHash() { |
| 1981 Object* hash = GetSimpleHash(this); | 2001 Object* hash = GetSimpleHash(this); |
| 1982 if (hash->IsSmi()) return hash; | 2002 if (hash->IsSmi()) return hash; |
| 1983 | 2003 |
| 1984 DisallowHeapAllocation no_gc; | 2004 DisallowHeapAllocation no_gc; |
| 1985 DCHECK(IsJSReceiver()); | 2005 DCHECK(IsJSReceiver()); |
| 1986 JSReceiver* receiver = JSReceiver::cast(this); | 2006 JSReceiver* receiver = JSReceiver::cast(this); |
| 1987 Isolate* isolate = receiver->GetIsolate(); | 2007 Isolate* isolate = receiver->GetIsolate(); |
| 1988 return JSReceiver::GetIdentityHash(isolate, handle(receiver, isolate)); | 2008 return JSReceiver::GetIdentityHash(isolate, handle(receiver, isolate)); |
| 1989 } | 2009 } |
| (...skipping 18106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20096 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) | 20116 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) |
| 20097 .Check(); | 20117 .Check(); |
| 20098 } | 20118 } |
| 20099 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); | 20119 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); |
| 20100 | 20120 |
| 20101 return ns; | 20121 return ns; |
| 20102 } | 20122 } |
| 20103 | 20123 |
| 20104 } // namespace internal | 20124 } // namespace internal |
| 20105 } // namespace v8 | 20125 } // namespace v8 |
| OLD | NEW |