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" |
31 #include "objects.h" | 32 #include "objects.h" |
32 | 33 |
33 namespace v8 { | 34 namespace v8 { |
34 namespace internal { | 35 namespace internal { |
35 | 36 |
36 // A Handle can be converted into a MaybeHandle. Converting a MaybeHandle | 37 // A Handle can be converted into a MaybeHandle. Converting a MaybeHandle |
37 // into a Handle requires checking that it does not point to NULL. This | 38 // into a Handle requires checking that it does not point to NULL. This |
38 // ensures NULL checks before use. | 39 // ensures NULL checks before use. |
39 // Do not use MaybeHandle as argument type. | 40 // Do not use MaybeHandle as argument type. |
40 | 41 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 274 |
274 #ifdef DEBUG | 275 #ifdef DEBUG |
275 bool handles_detached_; | 276 bool handles_detached_; |
276 int prev_level_; | 277 int prev_level_; |
277 #endif | 278 #endif |
278 | 279 |
279 friend class HandleScopeImplementer; | 280 friend class HandleScopeImplementer; |
280 }; | 281 }; |
281 | 282 |
282 | 283 |
| 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 |
283 // Seal off the current HandleScope so that new handles can only be created | 331 // Seal off the current HandleScope so that new handles can only be created |
284 // if a new HandleScope is entered. | 332 // if a new HandleScope is entered. |
285 class SealHandleScope BASE_EMBEDDED { | 333 class SealHandleScope BASE_EMBEDDED { |
286 public: | 334 public: |
287 #ifndef DEBUG | 335 #ifndef DEBUG |
288 explicit SealHandleScope(Isolate* isolate) {} | 336 explicit SealHandleScope(Isolate* isolate) {} |
289 ~SealHandleScope() {} | 337 ~SealHandleScope() {} |
290 #else | 338 #else |
291 explicit inline SealHandleScope(Isolate* isolate); | 339 explicit inline SealHandleScope(Isolate* isolate); |
292 inline ~SealHandleScope(); | 340 inline ~SealHandleScope(); |
(...skipping 11 matching lines...) Expand all Loading... |
304 | 352 |
305 void Initialize() { | 353 void Initialize() { |
306 next = limit = NULL; | 354 next = limit = NULL; |
307 level = 0; | 355 level = 0; |
308 } | 356 } |
309 }; | 357 }; |
310 | 358 |
311 } } // namespace v8::internal | 359 } } // namespace v8::internal |
312 | 360 |
313 #endif // V8_HANDLES_H_ | 361 #endif // V8_HANDLES_H_ |
OLD | NEW |