OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 void Lookup(Name* name, LookupResult* result); | 1528 void Lookup(Name* name, LookupResult* result); |
1529 | 1529 |
1530 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithReceiver( | 1530 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithReceiver( |
1531 Handle<Object> object, | 1531 Handle<Object> object, |
1532 Handle<Object> receiver, | 1532 Handle<Object> receiver, |
1533 Handle<Name> name, | 1533 Handle<Name> name, |
1534 PropertyAttributes* attributes); | 1534 PropertyAttributes* attributes); |
1535 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement( | 1535 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement( |
1536 Handle<Object> object, | 1536 Handle<Object> object, |
1537 Handle<Name> key); | 1537 Handle<Name> key); |
1538 | 1538 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( |
| 1539 Isolate* isolate, |
| 1540 Handle<Object> object, |
| 1541 const char* key); |
1539 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( | 1542 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( |
1540 Handle<Object> object, | 1543 Handle<Object> object, |
1541 Handle<Name> key); | 1544 Handle<Name> key); |
1542 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( | 1545 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( |
1543 Handle<Object> object, | 1546 Handle<Object> object, |
1544 Handle<Object> receiver, | 1547 Handle<Object> receiver, |
1545 LookupResult* result, | 1548 LookupResult* result, |
1546 Handle<Name> key, | 1549 Handle<Name> key, |
1547 PropertyAttributes* attributes); | 1550 PropertyAttributes* attributes); |
1548 | 1551 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 // hash code if needed and none exists. | 2104 // hash code if needed and none exists. |
2102 inline static Handle<Object> GetOrCreateIdentityHash( | 2105 inline static Handle<Object> GetOrCreateIdentityHash( |
2103 Handle<JSReceiver> object); | 2106 Handle<JSReceiver> object); |
2104 | 2107 |
2105 // Lookup a property. If found, the result is valid and has | 2108 // Lookup a property. If found, the result is valid and has |
2106 // detailed information. | 2109 // detailed information. |
2107 void LocalLookup(Name* name, LookupResult* result, | 2110 void LocalLookup(Name* name, LookupResult* result, |
2108 bool search_hidden_prototypes = false); | 2111 bool search_hidden_prototypes = false); |
2109 void Lookup(Name* name, LookupResult* result); | 2112 void Lookup(Name* name, LookupResult* result); |
2110 | 2113 |
| 2114 enum KeyCollectionType { LOCAL_ONLY, INCLUDE_PROTOS }; |
| 2115 |
| 2116 // Computes the enumerable keys for a JSObject. Used for implementing |
| 2117 // "for (n in object) { }". |
| 2118 MUST_USE_RESULT static MaybeHandle<FixedArray> GetKeys( |
| 2119 Handle<JSReceiver> object, |
| 2120 KeyCollectionType type); |
| 2121 |
2111 protected: | 2122 protected: |
2112 Smi* GenerateIdentityHash(); | 2123 Smi* GenerateIdentityHash(); |
2113 | 2124 |
2114 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( | 2125 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( |
2115 Handle<JSReceiver> object, | 2126 Handle<JSReceiver> object, |
2116 Handle<JSReceiver> setter, | 2127 Handle<JSReceiver> setter, |
2117 Handle<Object> value); | 2128 Handle<Object> value); |
2118 | 2129 |
2119 private: | 2130 private: |
2120 static PropertyAttributes GetPropertyAttributeForResult( | 2131 static PropertyAttributes GetPropertyAttributeForResult( |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2516 int length); | 2527 int length); |
2517 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( | 2528 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
2518 int capacity, | 2529 int capacity, |
2519 int length); | 2530 int length); |
2520 | 2531 |
2521 // Lookup interceptors are used for handling properties controlled by host | 2532 // Lookup interceptors are used for handling properties controlled by host |
2522 // objects. | 2533 // objects. |
2523 inline bool HasNamedInterceptor(); | 2534 inline bool HasNamedInterceptor(); |
2524 inline bool HasIndexedInterceptor(); | 2535 inline bool HasIndexedInterceptor(); |
2525 | 2536 |
| 2537 // Computes the enumerable keys from interceptors. Used for debug mirrors and |
| 2538 // by JSReceiver::GetKeys. |
| 2539 MUST_USE_RESULT static MaybeHandle<JSArray> GetKeysForNamedInterceptor( |
| 2540 Handle<JSObject> object, |
| 2541 Handle<JSReceiver> receiver); |
| 2542 MUST_USE_RESULT static MaybeHandle<JSArray> GetKeysForIndexedInterceptor( |
| 2543 Handle<JSObject> object, |
| 2544 Handle<JSReceiver> receiver); |
| 2545 |
2526 // Support functions for v8 api (needed for correct interceptor behavior). | 2546 // Support functions for v8 api (needed for correct interceptor behavior). |
2527 static bool HasRealNamedProperty(Handle<JSObject> object, | 2547 static bool HasRealNamedProperty(Handle<JSObject> object, |
2528 Handle<Name> key); | 2548 Handle<Name> key); |
2529 static bool HasRealElementProperty(Handle<JSObject> object, uint32_t index); | 2549 static bool HasRealElementProperty(Handle<JSObject> object, uint32_t index); |
2530 static bool HasRealNamedCallbackProperty(Handle<JSObject> object, | 2550 static bool HasRealNamedCallbackProperty(Handle<JSObject> object, |
2531 Handle<Name> key); | 2551 Handle<Name> key); |
2532 | 2552 |
2533 // Get the header size for a JSObject. Used to compute the index of | 2553 // Get the header size for a JSObject. Used to compute the index of |
2534 // internal fields as well as the number of internal fields. | 2554 // internal fields as well as the number of internal fields. |
2535 inline int GetHeaderSize(); | 2555 inline int GetHeaderSize(); |
(...skipping 4298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6834 // script's level of privilege. V8 just passes this through. Encoded in | 6854 // script's level of privilege. V8 just passes this through. Encoded in |
6835 // the 'flags' field. | 6855 // the 'flags' field. |
6836 DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin) | 6856 DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin) |
6837 | 6857 |
6838 static inline Script* cast(Object* obj); | 6858 static inline Script* cast(Object* obj); |
6839 | 6859 |
6840 // If script source is an external string, check that the underlying | 6860 // If script source is an external string, check that the underlying |
6841 // resource is accessible. Otherwise, always return true. | 6861 // resource is accessible. Otherwise, always return true. |
6842 inline bool HasValidSource(); | 6862 inline bool HasValidSource(); |
6843 | 6863 |
| 6864 // Convert code position into column number. |
| 6865 static int GetColumnNumber(Handle<Script> script, int code_pos); |
| 6866 |
| 6867 // Convert code position into (zero-based) line number. |
| 6868 // The non-handlified version does not allocate, but may be much slower. |
| 6869 static int GetLineNumber(Handle<Script> script, int code_pos); |
| 6870 int GetLineNumber(int code_pos); |
| 6871 |
| 6872 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
| 6873 |
| 6874 // Init line_ends array with code positions of line ends inside script source. |
| 6875 static void InitLineEnds(Handle<Script> script); |
| 6876 |
| 6877 // Get the JS object wrapping the given script; create it if none exists. |
| 6878 static Handle<JSObject> GetWrapper(Handle<Script> script); |
| 6879 |
6844 // Dispatched behavior. | 6880 // Dispatched behavior. |
6845 DECLARE_PRINTER(Script) | 6881 DECLARE_PRINTER(Script) |
6846 DECLARE_VERIFIER(Script) | 6882 DECLARE_VERIFIER(Script) |
6847 | 6883 |
6848 static const int kSourceOffset = HeapObject::kHeaderSize; | 6884 static const int kSourceOffset = HeapObject::kHeaderSize; |
6849 static const int kNameOffset = kSourceOffset + kPointerSize; | 6885 static const int kNameOffset = kSourceOffset + kPointerSize; |
6850 static const int kLineOffsetOffset = kNameOffset + kPointerSize; | 6886 static const int kLineOffsetOffset = kNameOffset + kPointerSize; |
6851 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; | 6887 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; |
6852 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; | 6888 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; |
6853 static const int kWrapperOffset = kContextOffset + kPointerSize; | 6889 static const int kWrapperOffset = kContextOffset + kPointerSize; |
6854 static const int kTypeOffset = kWrapperOffset + kPointerSize; | 6890 static const int kTypeOffset = kWrapperOffset + kPointerSize; |
6855 static const int kLineEndsOffset = kTypeOffset + kPointerSize; | 6891 static const int kLineEndsOffset = kTypeOffset + kPointerSize; |
6856 static const int kIdOffset = kLineEndsOffset + kPointerSize; | 6892 static const int kIdOffset = kLineEndsOffset + kPointerSize; |
6857 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; | 6893 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
6858 static const int kEvalFrominstructionsOffsetOffset = | 6894 static const int kEvalFrominstructionsOffsetOffset = |
6859 kEvalFromSharedOffset + kPointerSize; | 6895 kEvalFromSharedOffset + kPointerSize; |
6860 static const int kFlagsOffset = | 6896 static const int kFlagsOffset = |
6861 kEvalFrominstructionsOffsetOffset + kPointerSize; | 6897 kEvalFrominstructionsOffsetOffset + kPointerSize; |
6862 static const int kSize = kFlagsOffset + kPointerSize; | 6898 static const int kSize = kFlagsOffset + kPointerSize; |
6863 | 6899 |
6864 private: | 6900 private: |
| 6901 int GetLineNumberWithArray(int code_pos); |
| 6902 |
6865 // Bit positions in the flags field. | 6903 // Bit positions in the flags field. |
6866 static const int kCompilationTypeBit = 0; | 6904 static const int kCompilationTypeBit = 0; |
6867 static const int kCompilationStateBit = 1; | 6905 static const int kCompilationStateBit = 1; |
6868 static const int kIsSharedCrossOriginBit = 2; | 6906 static const int kIsSharedCrossOriginBit = 2; |
6869 | 6907 |
6870 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); | 6908 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); |
6871 }; | 6909 }; |
6872 | 6910 |
6873 | 6911 |
6874 // List of builtin functions we want to identify to improve code | 6912 // List of builtin functions we want to identify to improve code |
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9232 int32_t type); | 9270 int32_t type); |
9233 | 9271 |
9234 template<class Visitor> | 9272 template<class Visitor> |
9235 static inline ConsString* VisitFlat(Visitor* visitor, | 9273 static inline ConsString* VisitFlat(Visitor* visitor, |
9236 String* string, | 9274 String* string, |
9237 int offset = 0) { | 9275 int offset = 0) { |
9238 int32_t type = string->map()->instance_type(); | 9276 int32_t type = string->map()->instance_type(); |
9239 return VisitFlat(visitor, string, offset, string->length(), type); | 9277 return VisitFlat(visitor, string, offset, string->length(), type); |
9240 } | 9278 } |
9241 | 9279 |
| 9280 static Handle<FixedArray> CalculateLineEnds(Handle<String> string, |
| 9281 bool include_ending_line); |
| 9282 |
9242 private: | 9283 private: |
9243 friend class Name; | 9284 friend class Name; |
9244 | 9285 |
9245 static Handle<String> SlowFlatten(Handle<ConsString> cons, | 9286 static Handle<String> SlowFlatten(Handle<ConsString> cons, |
9246 PretenureFlag tenure); | 9287 PretenureFlag tenure); |
9247 | 9288 |
9248 // Slow case of String::Equals. This implementation works on any strings | 9289 // Slow case of String::Equals. This implementation works on any strings |
9249 // but it is most efficient on strings that are almost flat. | 9290 // but it is most efficient on strings that are almost flat. |
9250 bool SlowEquals(String* other); | 9291 bool SlowEquals(String* other); |
9251 | 9292 |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11054 } else { | 11095 } else { |
11055 value &= ~(1 << bit_position); | 11096 value &= ~(1 << bit_position); |
11056 } | 11097 } |
11057 return value; | 11098 return value; |
11058 } | 11099 } |
11059 }; | 11100 }; |
11060 | 11101 |
11061 } } // namespace v8::internal | 11102 } } // namespace v8::internal |
11062 | 11103 |
11063 #endif // V8_OBJECTS_H_ | 11104 #endif // V8_OBJECTS_H_ |
OLD | NEW |