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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 const int kRecursionBudget = 100; | 951 const int kRecursionBudget = 100; |
952 do { | 952 do { |
953 failure = false; | 953 failure = false; |
954 len = Utf8LengthHelper( | 954 len = Utf8LengthHelper( |
955 *str, 0, str->length(), false, kRecursionBudget, &failure, &dummy); | 955 *str, 0, str->length(), false, kRecursionBudget, &failure, &dummy); |
956 if (failure) FlattenString(str); | 956 if (failure) FlattenString(str); |
957 } while (failure); | 957 } while (failure); |
958 return len; | 958 return len; |
959 } | 959 } |
960 | 960 |
| 961 |
| 962 DeferredHandleScope::DeferredHandleScope(Isolate* isolate) |
| 963 : impl_(isolate->handle_scope_implementer()) { |
| 964 impl_->BeginDeferredScope(); |
| 965 Object** new_next = impl_->GetSpareOrNewBlock(); |
| 966 Object** new_limit = &new_next[kHandleBlockSize]; |
| 967 impl_->blocks()->Add(new_next); |
| 968 |
| 969 v8::ImplementationUtilities::HandleScopeData* data = |
| 970 impl_->isolate()->handle_scope_data(); |
| 971 #ifdef DEBUG |
| 972 prev_level_ = data->level; |
| 973 #endif |
| 974 data->level++; |
| 975 prev_limit_ = data->limit; |
| 976 prev_next_ = data->next; |
| 977 data->next = new_next; |
| 978 data->limit = new_limit; |
| 979 } |
| 980 |
| 981 |
| 982 DeferredHandleScope::~DeferredHandleScope() { |
| 983 impl_->isolate()->handle_scope_data()->level--; |
| 984 ASSERT(handles_detached_); |
| 985 ASSERT(impl_->isolate()->handle_scope_data()->level == prev_level_); |
| 986 } |
| 987 |
| 988 |
| 989 DeferredHandles* DeferredHandleScope::Detach() { |
| 990 DeferredHandles* deferred = impl_->Detach(prev_limit_); |
| 991 v8::ImplementationUtilities::HandleScopeData* data = |
| 992 impl_->isolate()->handle_scope_data(); |
| 993 data->next = prev_next_; |
| 994 data->limit = prev_limit_; |
| 995 #ifdef DEBUG |
| 996 handles_detached_ = true; |
| 997 #endif |
| 998 return deferred; |
| 999 } |
| 1000 |
| 1001 |
961 } } // namespace v8::internal | 1002 } } // namespace v8::internal |
OLD | NEW |