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 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 Handle<Object> rhs); | 1295 Handle<Object> rhs); |
1296 | 1296 |
1297 // ES6 section 7.3.19 OrdinaryHasInstance (C, O). | 1297 // ES6 section 7.3.19 OrdinaryHasInstance (C, O). |
1298 MUST_USE_RESULT static MaybeHandle<Object> OrdinaryHasInstance( | 1298 MUST_USE_RESULT static MaybeHandle<Object> OrdinaryHasInstance( |
1299 Isolate* isolate, Handle<Object> callable, Handle<Object> object); | 1299 Isolate* isolate, Handle<Object> callable, Handle<Object> object); |
1300 | 1300 |
1301 // ES6 section 12.10.4 Runtime Semantics: InstanceofOperator(O, C) | 1301 // ES6 section 12.10.4 Runtime Semantics: InstanceofOperator(O, C) |
1302 MUST_USE_RESULT static MaybeHandle<Object> InstanceOf( | 1302 MUST_USE_RESULT static MaybeHandle<Object> InstanceOf( |
1303 Isolate* isolate, Handle<Object> object, Handle<Object> callable); | 1303 Isolate* isolate, Handle<Object> object, Handle<Object> callable); |
1304 | 1304 |
1305 MUST_USE_RESULT static MaybeHandle<Object> GetProperty(LookupIterator* it); | 1305 V8_EXPORT_PRIVATE MUST_USE_RESULT static MaybeHandle<Object> GetProperty( |
| 1306 LookupIterator* it); |
1306 | 1307 |
1307 // ES6 [[Set]] (when passed DONT_THROW) | 1308 // ES6 [[Set]] (when passed DONT_THROW) |
1308 // Invariants for this and related functions (unless stated otherwise): | 1309 // Invariants for this and related functions (unless stated otherwise): |
1309 // 1) When the result is Nothing, an exception is pending. | 1310 // 1) When the result is Nothing, an exception is pending. |
1310 // 2) When passed THROW_ON_ERROR, the result is never Just(false). | 1311 // 2) When passed THROW_ON_ERROR, the result is never Just(false). |
1311 // In some cases, an exception is thrown regardless of the ShouldThrow | 1312 // In some cases, an exception is thrown regardless of the ShouldThrow |
1312 // argument. These cases are either in accordance with the spec or not | 1313 // argument. These cases are either in accordance with the spec or not |
1313 // covered by it (eg., concerning API callbacks). | 1314 // covered by it (eg., concerning API callbacks). |
1314 MUST_USE_RESULT static Maybe<bool> SetProperty(LookupIterator* it, | 1315 MUST_USE_RESULT static Maybe<bool> SetProperty(LookupIterator* it, |
1315 Handle<Object> value, | 1316 Handle<Object> value, |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 PropertyDescriptor* current, Handle<Name> property_name, | 1959 PropertyDescriptor* current, Handle<Name> property_name, |
1959 ShouldThrow should_throw); | 1960 ShouldThrow should_throw); |
1960 // ES6 9.1.6.3 | 1961 // ES6 9.1.6.3 |
1961 // |it| can be NULL in cases where the ES spec passes |undefined| as the | 1962 // |it| can be NULL in cases where the ES spec passes |undefined| as the |
1962 // receiver. Exactly one of |it| and |property_name| must be provided. | 1963 // receiver. Exactly one of |it| and |property_name| must be provided. |
1963 MUST_USE_RESULT static Maybe<bool> ValidateAndApplyPropertyDescriptor( | 1964 MUST_USE_RESULT static Maybe<bool> ValidateAndApplyPropertyDescriptor( |
1964 Isolate* isolate, LookupIterator* it, bool extensible, | 1965 Isolate* isolate, LookupIterator* it, bool extensible, |
1965 PropertyDescriptor* desc, PropertyDescriptor* current, | 1966 PropertyDescriptor* desc, PropertyDescriptor* current, |
1966 ShouldThrow should_throw, Handle<Name> property_name = Handle<Name>()); | 1967 ShouldThrow should_throw, Handle<Name> property_name = Handle<Name>()); |
1967 | 1968 |
1968 MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor( | 1969 V8_EXPORT_PRIVATE MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor( |
1969 Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key, | 1970 Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key, |
1970 PropertyDescriptor* desc); | 1971 PropertyDescriptor* desc); |
1971 MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor( | 1972 MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor( |
1972 LookupIterator* it, PropertyDescriptor* desc); | 1973 LookupIterator* it, PropertyDescriptor* desc); |
1973 | 1974 |
1974 typedef PropertyAttributes IntegrityLevel; | 1975 typedef PropertyAttributes IntegrityLevel; |
1975 | 1976 |
1976 // ES6 7.3.14 (when passed DONT_THROW) | 1977 // ES6 7.3.14 (when passed DONT_THROW) |
1977 // 'level' must be SEALED or FROZEN. | 1978 // 'level' must be SEALED or FROZEN. |
1978 MUST_USE_RESULT static Maybe<bool> SetIntegrityLevel( | 1979 MUST_USE_RESULT static Maybe<bool> SetIntegrityLevel( |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3497 // StringTable. | 3498 // StringTable. |
3498 // | 3499 // |
3499 // No special elements in the prefix and the element size is 1 | 3500 // No special elements in the prefix and the element size is 1 |
3500 // because only the string itself (the key) needs to be stored. | 3501 // because only the string itself (the key) needs to be stored. |
3501 class StringTable: public HashTable<StringTable, | 3502 class StringTable: public HashTable<StringTable, |
3502 StringTableShape, | 3503 StringTableShape, |
3503 HashTableKey*> { | 3504 HashTableKey*> { |
3504 public: | 3505 public: |
3505 // Find string in the string table. If it is not there yet, it is | 3506 // Find string in the string table. If it is not there yet, it is |
3506 // added. The return value is the string found. | 3507 // added. The return value is the string found. |
3507 static Handle<String> LookupString(Isolate* isolate, Handle<String> key); | 3508 V8_EXPORT_PRIVATE static Handle<String> LookupString(Isolate* isolate, |
| 3509 Handle<String> key); |
3508 static Handle<String> LookupKey(Isolate* isolate, HashTableKey* key); | 3510 static Handle<String> LookupKey(Isolate* isolate, HashTableKey* key); |
3509 static String* LookupKeyIfExists(Isolate* isolate, HashTableKey* key); | 3511 static String* LookupKeyIfExists(Isolate* isolate, HashTableKey* key); |
3510 | 3512 |
3511 // Tries to internalize given string and returns string handle on success | 3513 // Tries to internalize given string and returns string handle on success |
3512 // or an empty handle otherwise. | 3514 // or an empty handle otherwise. |
3513 MUST_USE_RESULT static MaybeHandle<String> InternalizeStringIfExists( | 3515 MUST_USE_RESULT static MaybeHandle<String> InternalizeStringIfExists( |
3514 Isolate* isolate, | 3516 Isolate* isolate, |
3515 Handle<String> string); | 3517 Handle<String> string); |
3516 | 3518 |
3517 // Looks up a string that is equal to the given string and returns | 3519 // Looks up a string that is equal to the given string and returns |
(...skipping 5002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8520 kMultiline = 1 << 2, | 8522 kMultiline = 1 << 2, |
8521 kSticky = 1 << 3, | 8523 kSticky = 1 << 3, |
8522 kUnicode = 1 << 4, | 8524 kUnicode = 1 << 4, |
8523 }; | 8525 }; |
8524 typedef base::Flags<Flag> Flags; | 8526 typedef base::Flags<Flag> Flags; |
8525 | 8527 |
8526 DECL_ACCESSORS(data, Object) | 8528 DECL_ACCESSORS(data, Object) |
8527 DECL_ACCESSORS(flags, Object) | 8529 DECL_ACCESSORS(flags, Object) |
8528 DECL_ACCESSORS(source, Object) | 8530 DECL_ACCESSORS(source, Object) |
8529 | 8531 |
8530 static MaybeHandle<JSRegExp> New(Handle<String> source, Flags flags); | 8532 V8_EXPORT_PRIVATE static MaybeHandle<JSRegExp> New(Handle<String> source, |
| 8533 Flags flags); |
8531 static Handle<JSRegExp> Copy(Handle<JSRegExp> regexp); | 8534 static Handle<JSRegExp> Copy(Handle<JSRegExp> regexp); |
8532 | 8535 |
8533 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, | 8536 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, |
8534 Handle<String> source, Flags flags); | 8537 Handle<String> source, Flags flags); |
8535 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, | 8538 static MaybeHandle<JSRegExp> Initialize(Handle<JSRegExp> regexp, |
8536 Handle<String> source, | 8539 Handle<String> source, |
8537 Handle<String> flags_string); | 8540 Handle<String> flags_string); |
8538 | 8541 |
8539 inline Type TypeTag(); | 8542 inline Type TypeTag(); |
8540 inline int CaptureCount(); | 8543 inline int CaptureCount(); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8977 static const int kSize = kAliasedContextSlot + kPointerSize; | 8980 static const int kSize = kAliasedContextSlot + kPointerSize; |
8978 | 8981 |
8979 private: | 8982 private: |
8980 DISALLOW_IMPLICIT_CONSTRUCTORS(AliasedArgumentsEntry); | 8983 DISALLOW_IMPLICIT_CONSTRUCTORS(AliasedArgumentsEntry); |
8981 }; | 8984 }; |
8982 | 8985 |
8983 | 8986 |
8984 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS}; | 8987 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS}; |
8985 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL}; | 8988 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL}; |
8986 | 8989 |
8987 | 8990 class V8_EXPORT_PRIVATE StringHasher { |
8988 class StringHasher { | |
8989 public: | 8991 public: |
8990 explicit inline StringHasher(int length, uint32_t seed); | 8992 explicit inline StringHasher(int length, uint32_t seed); |
8991 | 8993 |
8992 template <typename schar> | 8994 template <typename schar> |
8993 static inline uint32_t HashSequentialString(const schar* chars, | 8995 static inline uint32_t HashSequentialString(const schar* chars, |
8994 int length, | 8996 int length, |
8995 uint32_t seed); | 8997 uint32_t seed); |
8996 | 8998 |
8997 // Reads all the data, even for long strings and computes the utf16 length. | 8999 // Reads all the data, even for long strings and computes the utf16 length. |
8998 static uint32_t ComputeUtf8Hash(Vector<const char> chars, | 9000 static uint32_t ComputeUtf8Hash(Vector<const char> chars, |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9601 static Handle<String> SlowFlatten(Handle<ConsString> cons, | 9603 static Handle<String> SlowFlatten(Handle<ConsString> cons, |
9602 PretenureFlag tenure); | 9604 PretenureFlag tenure); |
9603 | 9605 |
9604 // Slow case of String::Equals. This implementation works on any strings | 9606 // Slow case of String::Equals. This implementation works on any strings |
9605 // but it is most efficient on strings that are almost flat. | 9607 // but it is most efficient on strings that are almost flat. |
9606 bool SlowEquals(String* other); | 9608 bool SlowEquals(String* other); |
9607 | 9609 |
9608 static bool SlowEquals(Handle<String> one, Handle<String> two); | 9610 static bool SlowEquals(Handle<String> one, Handle<String> two); |
9609 | 9611 |
9610 // Slow case of AsArrayIndex. | 9612 // Slow case of AsArrayIndex. |
9611 bool SlowAsArrayIndex(uint32_t* index); | 9613 V8_EXPORT_PRIVATE bool SlowAsArrayIndex(uint32_t* index); |
9612 | 9614 |
9613 // Compute and set the hash code. | 9615 // Compute and set the hash code. |
9614 uint32_t ComputeAndSetHash(); | 9616 uint32_t ComputeAndSetHash(); |
9615 | 9617 |
9616 DISALLOW_IMPLICIT_CONSTRUCTORS(String); | 9618 DISALLOW_IMPLICIT_CONSTRUCTORS(String); |
9617 }; | 9619 }; |
9618 | 9620 |
9619 | 9621 |
9620 // The SeqString abstract class captures sequential string values. | 9622 // The SeqString abstract class captures sequential string values. |
9621 class SeqString: public String { | 9623 class SeqString: public String { |
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11432 } | 11434 } |
11433 return value; | 11435 return value; |
11434 } | 11436 } |
11435 }; | 11437 }; |
11436 | 11438 |
11437 | 11439 |
11438 } // NOLINT, false-positive due to second-order macros. | 11440 } // NOLINT, false-positive due to second-order macros. |
11439 } // NOLINT, false-positive due to second-order macros. | 11441 } // NOLINT, false-positive due to second-order macros. |
11440 | 11442 |
11441 #endif // V8_OBJECTS_H_ | 11443 #endif // V8_OBJECTS_H_ |
OLD | NEW |