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 4291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6827 // script's level of privilege. V8 just passes this through. Encoded in | 6847 // script's level of privilege. V8 just passes this through. Encoded in |
6828 // the 'flags' field. | 6848 // the 'flags' field. |
6829 DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin) | 6849 DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin) |
6830 | 6850 |
6831 static inline Script* cast(Object* obj); | 6851 static inline Script* cast(Object* obj); |
6832 | 6852 |
6833 // If script source is an external string, check that the underlying | 6853 // If script source is an external string, check that the underlying |
6834 // resource is accessible. Otherwise, always return true. | 6854 // resource is accessible. Otherwise, always return true. |
6835 inline bool HasValidSource(); | 6855 inline bool HasValidSource(); |
6836 | 6856 |
| 6857 // Convert code position into column number. |
| 6858 static int GetColumnNumber(Handle<Script> script, int code_pos); |
| 6859 |
| 6860 // Convert code position into (zero-based) line number. |
| 6861 // The non-handlified version does not allocate, but may be much slower. |
| 6862 static int GetLineNumber(Handle<Script> script, int code_pos); |
| 6863 int GetLineNumber(int code_pos); |
| 6864 |
| 6865 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
| 6866 |
| 6867 // Init line_ends array with code positions of line ends inside script source. |
| 6868 static void InitLineEnds(Handle<Script> script); |
| 6869 |
| 6870 // Get the JS object wrapping the given script; create it if none exists. |
| 6871 static Handle<JSObject> GetWrapper(Handle<Script> script); |
| 6872 |
6837 // Dispatched behavior. | 6873 // Dispatched behavior. |
6838 DECLARE_PRINTER(Script) | 6874 DECLARE_PRINTER(Script) |
6839 DECLARE_VERIFIER(Script) | 6875 DECLARE_VERIFIER(Script) |
6840 | 6876 |
6841 static const int kSourceOffset = HeapObject::kHeaderSize; | 6877 static const int kSourceOffset = HeapObject::kHeaderSize; |
6842 static const int kNameOffset = kSourceOffset + kPointerSize; | 6878 static const int kNameOffset = kSourceOffset + kPointerSize; |
6843 static const int kLineOffsetOffset = kNameOffset + kPointerSize; | 6879 static const int kLineOffsetOffset = kNameOffset + kPointerSize; |
6844 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; | 6880 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; |
6845 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; | 6881 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; |
6846 static const int kWrapperOffset = kContextOffset + kPointerSize; | 6882 static const int kWrapperOffset = kContextOffset + kPointerSize; |
6847 static const int kTypeOffset = kWrapperOffset + kPointerSize; | 6883 static const int kTypeOffset = kWrapperOffset + kPointerSize; |
6848 static const int kLineEndsOffset = kTypeOffset + kPointerSize; | 6884 static const int kLineEndsOffset = kTypeOffset + kPointerSize; |
6849 static const int kIdOffset = kLineEndsOffset + kPointerSize; | 6885 static const int kIdOffset = kLineEndsOffset + kPointerSize; |
6850 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; | 6886 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
6851 static const int kEvalFrominstructionsOffsetOffset = | 6887 static const int kEvalFrominstructionsOffsetOffset = |
6852 kEvalFromSharedOffset + kPointerSize; | 6888 kEvalFromSharedOffset + kPointerSize; |
6853 static const int kFlagsOffset = | 6889 static const int kFlagsOffset = |
6854 kEvalFrominstructionsOffsetOffset + kPointerSize; | 6890 kEvalFrominstructionsOffsetOffset + kPointerSize; |
6855 static const int kSize = kFlagsOffset + kPointerSize; | 6891 static const int kSize = kFlagsOffset + kPointerSize; |
6856 | 6892 |
6857 private: | 6893 private: |
| 6894 int GetLineNumberWithArray(int code_pos); |
| 6895 |
6858 // Bit positions in the flags field. | 6896 // Bit positions in the flags field. |
6859 static const int kCompilationTypeBit = 0; | 6897 static const int kCompilationTypeBit = 0; |
6860 static const int kCompilationStateBit = 1; | 6898 static const int kCompilationStateBit = 1; |
6861 static const int kIsSharedCrossOriginBit = 2; | 6899 static const int kIsSharedCrossOriginBit = 2; |
6862 | 6900 |
6863 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); | 6901 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); |
6864 }; | 6902 }; |
6865 | 6903 |
6866 | 6904 |
6867 // List of builtin functions we want to identify to improve code | 6905 // List of builtin functions we want to identify to improve code |
(...skipping 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9217 int32_t type); | 9255 int32_t type); |
9218 | 9256 |
9219 template<class Visitor> | 9257 template<class Visitor> |
9220 static inline ConsString* VisitFlat(Visitor* visitor, | 9258 static inline ConsString* VisitFlat(Visitor* visitor, |
9221 String* string, | 9259 String* string, |
9222 int offset = 0) { | 9260 int offset = 0) { |
9223 int32_t type = string->map()->instance_type(); | 9261 int32_t type = string->map()->instance_type(); |
9224 return VisitFlat(visitor, string, offset, string->length(), type); | 9262 return VisitFlat(visitor, string, offset, string->length(), type); |
9225 } | 9263 } |
9226 | 9264 |
| 9265 static Handle<FixedArray> CalculateLineEnds(Handle<String> string, |
| 9266 bool include_ending_line); |
| 9267 |
9227 private: | 9268 private: |
9228 friend class Name; | 9269 friend class Name; |
9229 | 9270 |
9230 static Handle<String> SlowFlatten(Handle<ConsString> cons, | 9271 static Handle<String> SlowFlatten(Handle<ConsString> cons, |
9231 PretenureFlag tenure); | 9272 PretenureFlag tenure); |
9232 | 9273 |
9233 // Slow case of String::Equals. This implementation works on any strings | 9274 // Slow case of String::Equals. This implementation works on any strings |
9234 // but it is most efficient on strings that are almost flat. | 9275 // but it is most efficient on strings that are almost flat. |
9235 bool SlowEquals(String* other); | 9276 bool SlowEquals(String* other); |
9236 | 9277 |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11039 } else { | 11080 } else { |
11040 value &= ~(1 << bit_position); | 11081 value &= ~(1 << bit_position); |
11041 } | 11082 } |
11042 return value; | 11083 return value; |
11043 } | 11084 } |
11044 }; | 11085 }; |
11045 | 11086 |
11046 } } // namespace v8::internal | 11087 } } // namespace v8::internal |
11047 | 11088 |
11048 #endif // V8_OBJECTS_H_ | 11089 #endif // V8_OBJECTS_H_ |
OLD | NEW |