OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_HANDLES_H_ | 28 #ifndef V8_HANDLES_H_ |
29 #define V8_HANDLES_H_ | 29 #define V8_HANDLES_H_ |
30 | 30 |
31 #include "allocation.h" | |
32 #include "objects.h" | 31 #include "objects.h" |
33 | 32 |
34 namespace v8 { | 33 namespace v8 { |
35 namespace internal { | 34 namespace internal { |
36 | 35 |
37 // A Handle can be converted into a MaybeHandle. Converting a MaybeHandle | 36 // A Handle can be converted into a MaybeHandle. Converting a MaybeHandle |
38 // into a Handle requires checking that it does not point to NULL. This | 37 // into a Handle requires checking that it does not point to NULL. This |
39 // ensures NULL checks before use. | 38 // ensures NULL checks before use. |
40 // Do not use MaybeHandle as argument type. | 39 // Do not use MaybeHandle as argument type. |
41 | 40 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 273 |
275 #ifdef DEBUG | 274 #ifdef DEBUG |
276 bool handles_detached_; | 275 bool handles_detached_; |
277 int prev_level_; | 276 int prev_level_; |
278 #endif | 277 #endif |
279 | 278 |
280 friend class HandleScopeImplementer; | 279 friend class HandleScopeImplementer; |
281 }; | 280 }; |
282 | 281 |
283 | 282 |
284 // ---------------------------------------------------------------------------- | |
285 // Handle operations. | |
286 // They might invoke garbage collection. The result is an handle to | |
287 // an object of expected type, or the handle is an error if running out | |
288 // of space or encountering an internal error. | |
289 | |
290 MUST_USE_RESULT MaybeHandle<Object> GetProperty(Handle<JSReceiver> obj, | |
291 const char* name); | |
292 | |
293 // Get the JS object corresponding to the given script; create it | |
294 // if none exists. | |
295 Handle<JSValue> GetScriptWrapper(Handle<Script> script); | |
296 | |
297 // Script line number computations. Note that the line number is zero-based. | |
298 void InitScriptLineEnds(Handle<Script> script); | |
299 // For string calculates an array of line end positions. If the string | |
300 // does not end with a new line character, this character may optionally be | |
301 // imagined. | |
302 Handle<FixedArray> CalculateLineEnds(Handle<String> string, | |
303 bool with_imaginary_last_new_line); | |
304 int GetScriptLineNumber(Handle<Script> script, int code_position); | |
305 // The safe version does not make heap allocations but may work much slower. | |
306 int GetScriptLineNumberSafe(Handle<Script> script, int code_position); | |
307 int GetScriptColumnNumber(Handle<Script> script, int code_position); | |
308 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script); | |
309 | |
310 // Computes the enumerable keys from interceptors. Used for debug mirrors and | |
311 // by GetKeysInFixedArrayFor below. | |
312 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSReceiver> receiver, | |
313 Handle<JSObject> object); | |
314 v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSReceiver> receiver, | |
315 Handle<JSObject> object); | |
316 | |
317 enum KeyCollectionType { LOCAL_ONLY, INCLUDE_PROTOS }; | |
318 | |
319 // Computes the enumerable keys for a JSObject. Used for implementing | |
320 // "for (n in object) { }". | |
321 MUST_USE_RESULT MaybeHandle<FixedArray> GetKeysInFixedArrayFor( | |
322 Handle<JSReceiver> object, KeyCollectionType type); | |
323 Handle<FixedArray> ReduceFixedArrayTo(Handle<FixedArray> array, int length); | |
324 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, | |
325 bool cache_result); | |
326 | |
327 void AddWeakObjectToCodeDependency(Heap* heap, | |
328 Handle<Object> object, | |
329 Handle<Code> code); | |
330 | |
331 // Seal off the current HandleScope so that new handles can only be created | 283 // Seal off the current HandleScope so that new handles can only be created |
332 // if a new HandleScope is entered. | 284 // if a new HandleScope is entered. |
333 class SealHandleScope BASE_EMBEDDED { | 285 class SealHandleScope BASE_EMBEDDED { |
334 public: | 286 public: |
335 #ifndef DEBUG | 287 #ifndef DEBUG |
336 explicit SealHandleScope(Isolate* isolate) {} | 288 explicit SealHandleScope(Isolate* isolate) {} |
337 ~SealHandleScope() {} | 289 ~SealHandleScope() {} |
338 #else | 290 #else |
339 explicit inline SealHandleScope(Isolate* isolate); | 291 explicit inline SealHandleScope(Isolate* isolate); |
340 inline ~SealHandleScope(); | 292 inline ~SealHandleScope(); |
(...skipping 11 matching lines...) Expand all Loading... |
352 | 304 |
353 void Initialize() { | 305 void Initialize() { |
354 next = limit = NULL; | 306 next = limit = NULL; |
355 level = 0; | 307 level = 0; |
356 } | 308 } |
357 }; | 309 }; |
358 | 310 |
359 } } // namespace v8::internal | 311 } } // namespace v8::internal |
360 | 312 |
361 #endif // V8_HANDLES_H_ | 313 #endif // V8_HANDLES_H_ |
OLD | NEW |