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 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( | 1538 |
1539 Isolate* isolate, | |
1540 Handle<Object> object, | |
1541 const char* key); | |
1542 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( | 1539 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( |
1543 Handle<Object> object, | 1540 Handle<Object> object, |
1544 Handle<Name> key); | 1541 Handle<Name> key); |
1545 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( | 1542 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( |
1546 Handle<Object> object, | 1543 Handle<Object> object, |
1547 Handle<Object> receiver, | 1544 Handle<Object> receiver, |
1548 LookupResult* result, | 1545 LookupResult* result, |
1549 Handle<Name> key, | 1546 Handle<Name> key, |
1550 PropertyAttributes* attributes); | 1547 PropertyAttributes* attributes); |
1551 | 1548 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 // hash code if needed and none exists. | 2101 // hash code if needed and none exists. |
2105 inline static Handle<Object> GetOrCreateIdentityHash( | 2102 inline static Handle<Object> GetOrCreateIdentityHash( |
2106 Handle<JSReceiver> object); | 2103 Handle<JSReceiver> object); |
2107 | 2104 |
2108 // Lookup a property. If found, the result is valid and has | 2105 // Lookup a property. If found, the result is valid and has |
2109 // detailed information. | 2106 // detailed information. |
2110 void LocalLookup(Name* name, LookupResult* result, | 2107 void LocalLookup(Name* name, LookupResult* result, |
2111 bool search_hidden_prototypes = false); | 2108 bool search_hidden_prototypes = false); |
2112 void Lookup(Name* name, LookupResult* result); | 2109 void Lookup(Name* name, LookupResult* result); |
2113 | 2110 |
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 | |
2122 protected: | 2111 protected: |
2123 Smi* GenerateIdentityHash(); | 2112 Smi* GenerateIdentityHash(); |
2124 | 2113 |
2125 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( | 2114 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( |
2126 Handle<JSReceiver> object, | 2115 Handle<JSReceiver> object, |
2127 Handle<JSReceiver> setter, | 2116 Handle<JSReceiver> setter, |
2128 Handle<Object> value); | 2117 Handle<Object> value); |
2129 | 2118 |
2130 private: | 2119 private: |
2131 static PropertyAttributes GetPropertyAttributeForResult( | 2120 static PropertyAttributes GetPropertyAttributeForResult( |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 int length); | 2516 int length); |
2528 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( | 2517 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
2529 int capacity, | 2518 int capacity, |
2530 int length); | 2519 int length); |
2531 | 2520 |
2532 // Lookup interceptors are used for handling properties controlled by host | 2521 // Lookup interceptors are used for handling properties controlled by host |
2533 // objects. | 2522 // objects. |
2534 inline bool HasNamedInterceptor(); | 2523 inline bool HasNamedInterceptor(); |
2535 inline bool HasIndexedInterceptor(); | 2524 inline bool HasIndexedInterceptor(); |
2536 | 2525 |
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 | |
2546 // Support functions for v8 api (needed for correct interceptor behavior). | 2526 // Support functions for v8 api (needed for correct interceptor behavior). |
2547 static bool HasRealNamedProperty(Handle<JSObject> object, | 2527 static bool HasRealNamedProperty(Handle<JSObject> object, |
2548 Handle<Name> key); | 2528 Handle<Name> key); |
2549 static bool HasRealElementProperty(Handle<JSObject> object, uint32_t index); | 2529 static bool HasRealElementProperty(Handle<JSObject> object, uint32_t index); |
2550 static bool HasRealNamedCallbackProperty(Handle<JSObject> object, | 2530 static bool HasRealNamedCallbackProperty(Handle<JSObject> object, |
2551 Handle<Name> key); | 2531 Handle<Name> key); |
2552 | 2532 |
2553 // Get the header size for a JSObject. Used to compute the index of | 2533 // Get the header size for a JSObject. Used to compute the index of |
2554 // internal fields as well as the number of internal fields. | 2534 // internal fields as well as the number of internal fields. |
2555 inline int GetHeaderSize(); | 2535 inline int GetHeaderSize(); |
(...skipping 4298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6854 // script's level of privilege. V8 just passes this through. Encoded in | 6834 // script's level of privilege. V8 just passes this through. Encoded in |
6855 // the 'flags' field. | 6835 // the 'flags' field. |
6856 DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin) | 6836 DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin) |
6857 | 6837 |
6858 static inline Script* cast(Object* obj); | 6838 static inline Script* cast(Object* obj); |
6859 | 6839 |
6860 // If script source is an external string, check that the underlying | 6840 // If script source is an external string, check that the underlying |
6861 // resource is accessible. Otherwise, always return true. | 6841 // resource is accessible. Otherwise, always return true. |
6862 inline bool HasValidSource(); | 6842 inline bool HasValidSource(); |
6863 | 6843 |
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 | |
6880 // Dispatched behavior. | 6844 // Dispatched behavior. |
6881 DECLARE_PRINTER(Script) | 6845 DECLARE_PRINTER(Script) |
6882 DECLARE_VERIFIER(Script) | 6846 DECLARE_VERIFIER(Script) |
6883 | 6847 |
6884 static const int kSourceOffset = HeapObject::kHeaderSize; | 6848 static const int kSourceOffset = HeapObject::kHeaderSize; |
6885 static const int kNameOffset = kSourceOffset + kPointerSize; | 6849 static const int kNameOffset = kSourceOffset + kPointerSize; |
6886 static const int kLineOffsetOffset = kNameOffset + kPointerSize; | 6850 static const int kLineOffsetOffset = kNameOffset + kPointerSize; |
6887 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; | 6851 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; |
6888 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; | 6852 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; |
6889 static const int kWrapperOffset = kContextOffset + kPointerSize; | 6853 static const int kWrapperOffset = kContextOffset + kPointerSize; |
6890 static const int kTypeOffset = kWrapperOffset + kPointerSize; | 6854 static const int kTypeOffset = kWrapperOffset + kPointerSize; |
6891 static const int kLineEndsOffset = kTypeOffset + kPointerSize; | 6855 static const int kLineEndsOffset = kTypeOffset + kPointerSize; |
6892 static const int kIdOffset = kLineEndsOffset + kPointerSize; | 6856 static const int kIdOffset = kLineEndsOffset + kPointerSize; |
6893 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; | 6857 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
6894 static const int kEvalFrominstructionsOffsetOffset = | 6858 static const int kEvalFrominstructionsOffsetOffset = |
6895 kEvalFromSharedOffset + kPointerSize; | 6859 kEvalFromSharedOffset + kPointerSize; |
6896 static const int kFlagsOffset = | 6860 static const int kFlagsOffset = |
6897 kEvalFrominstructionsOffsetOffset + kPointerSize; | 6861 kEvalFrominstructionsOffsetOffset + kPointerSize; |
6898 static const int kSize = kFlagsOffset + kPointerSize; | 6862 static const int kSize = kFlagsOffset + kPointerSize; |
6899 | 6863 |
6900 private: | 6864 private: |
6901 int GetLineNumberWithArray(int code_pos); | |
6902 | |
6903 // Bit positions in the flags field. | 6865 // Bit positions in the flags field. |
6904 static const int kCompilationTypeBit = 0; | 6866 static const int kCompilationTypeBit = 0; |
6905 static const int kCompilationStateBit = 1; | 6867 static const int kCompilationStateBit = 1; |
6906 static const int kIsSharedCrossOriginBit = 2; | 6868 static const int kIsSharedCrossOriginBit = 2; |
6907 | 6869 |
6908 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); | 6870 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); |
6909 }; | 6871 }; |
6910 | 6872 |
6911 | 6873 |
6912 // List of builtin functions we want to identify to improve code | 6874 // List of builtin functions we want to identify to improve code |
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9270 int32_t type); | 9232 int32_t type); |
9271 | 9233 |
9272 template<class Visitor> | 9234 template<class Visitor> |
9273 static inline ConsString* VisitFlat(Visitor* visitor, | 9235 static inline ConsString* VisitFlat(Visitor* visitor, |
9274 String* string, | 9236 String* string, |
9275 int offset = 0) { | 9237 int offset = 0) { |
9276 int32_t type = string->map()->instance_type(); | 9238 int32_t type = string->map()->instance_type(); |
9277 return VisitFlat(visitor, string, offset, string->length(), type); | 9239 return VisitFlat(visitor, string, offset, string->length(), type); |
9278 } | 9240 } |
9279 | 9241 |
9280 static Handle<FixedArray> CalculateLineEnds(Handle<String> string, | |
9281 bool include_ending_line); | |
9282 | |
9283 private: | 9242 private: |
9284 friend class Name; | 9243 friend class Name; |
9285 | 9244 |
9286 static Handle<String> SlowFlatten(Handle<ConsString> cons, | 9245 static Handle<String> SlowFlatten(Handle<ConsString> cons, |
9287 PretenureFlag tenure); | 9246 PretenureFlag tenure); |
9288 | 9247 |
9289 // Slow case of String::Equals. This implementation works on any strings | 9248 // Slow case of String::Equals. This implementation works on any strings |
9290 // but it is most efficient on strings that are almost flat. | 9249 // but it is most efficient on strings that are almost flat. |
9291 bool SlowEquals(String* other); | 9250 bool SlowEquals(String* other); |
9292 | 9251 |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11095 } else { | 11054 } else { |
11096 value &= ~(1 << bit_position); | 11055 value &= ~(1 << bit_position); |
11097 } | 11056 } |
11098 return value; | 11057 return value; |
11099 } | 11058 } |
11100 }; | 11059 }; |
11101 | 11060 |
11102 } } // namespace v8::internal | 11061 } } // namespace v8::internal |
11103 | 11062 |
11104 #endif // V8_OBJECTS_H_ | 11063 #endif // V8_OBJECTS_H_ |
OLD | NEW |