OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 7886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7897 return String::ToCString(); | 7897 return String::ToCString(); |
7898 } | 7898 } |
7899 | 7899 |
7900 | 7900 |
7901 static void AddFinalizer(const Object& referent, | 7901 static void AddFinalizer(const Object& referent, |
7902 void* peer, | 7902 void* peer, |
7903 Dart_WeakPersistentHandleFinalizer callback) { | 7903 Dart_WeakPersistentHandleFinalizer callback) { |
7904 ASSERT(callback != NULL); | 7904 ASSERT(callback != NULL); |
7905 ApiState* state = Isolate::Current()->api_state(); | 7905 ApiState* state = Isolate::Current()->api_state(); |
7906 ASSERT(state != NULL); | 7906 ASSERT(state != NULL); |
7907 WeakPersistentHandle* weak_ref = | 7907 FinalizablePersistentHandle* weak_ref = |
7908 state->weak_persistent_handles().AllocateHandle(); | 7908 state->weak_persistent_handles().AllocateHandle(); |
7909 weak_ref->set_raw(referent); | 7909 weak_ref->set_raw(referent); |
7910 weak_ref->set_peer(peer); | 7910 weak_ref->set_peer(peer); |
7911 weak_ref->set_callback(callback); | 7911 weak_ref->set_callback(callback); |
7912 } | 7912 } |
7913 | 7913 |
7914 | 7914 |
7915 RawExternalOneByteString* ExternalOneByteString::New( | 7915 RawExternalOneByteString* ExternalOneByteString::New( |
7916 const uint8_t* data, | 7916 const uint8_t* data, |
7917 intptr_t len, | 7917 intptr_t len, |
(...skipping 18 matching lines...) Expand all Loading... |
7936 result.SetExternalData(external_data); | 7936 result.SetExternalData(external_data); |
7937 } | 7937 } |
7938 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); | 7938 AddFinalizer(result, external_data, ExternalOneByteString::Finalize); |
7939 return result.raw(); | 7939 return result.raw(); |
7940 } | 7940 } |
7941 | 7941 |
7942 | 7942 |
7943 static void DeleteWeakPersistentHandle(Dart_Handle handle) { | 7943 static void DeleteWeakPersistentHandle(Dart_Handle handle) { |
7944 ApiState* state = Isolate::Current()->api_state(); | 7944 ApiState* state = Isolate::Current()->api_state(); |
7945 ASSERT(state != NULL); | 7945 ASSERT(state != NULL); |
7946 WeakPersistentHandle* weak_ref = | 7946 FinalizablePersistentHandle* weak_ref = |
7947 reinterpret_cast<WeakPersistentHandle*>(handle); | 7947 reinterpret_cast<FinalizablePersistentHandle*>(handle); |
7948 ASSERT(state->IsValidWeakPersistentHandle(handle)); | 7948 ASSERT(state->IsValidWeakPersistentHandle(handle)); |
7949 state->weak_persistent_handles().FreeHandle(weak_ref); | 7949 state->weak_persistent_handles().FreeHandle(weak_ref); |
7950 } | 7950 } |
7951 | 7951 |
7952 | 7952 |
7953 void ExternalOneByteString::Finalize(Dart_Handle handle, void* peer) { | 7953 void ExternalOneByteString::Finalize(Dart_Handle handle, void* peer) { |
7954 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer); | 7954 delete reinterpret_cast<ExternalStringData<uint8_t>*>(peer); |
7955 DeleteWeakPersistentHandle(handle); | 7955 DeleteWeakPersistentHandle(handle); |
7956 } | 7956 } |
7957 | 7957 |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8769 const String& str = String::Handle(pattern()); | 8769 const String& str = String::Handle(pattern()); |
8770 const char* format = "JSRegExp: pattern=%s flags=%s"; | 8770 const char* format = "JSRegExp: pattern=%s flags=%s"; |
8771 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 8771 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
8772 char* chars = reinterpret_cast<char*>( | 8772 char* chars = reinterpret_cast<char*>( |
8773 Isolate::Current()->current_zone()->Allocate(len + 1)); | 8773 Isolate::Current()->current_zone()->Allocate(len + 1)); |
8774 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 8774 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
8775 return chars; | 8775 return chars; |
8776 } | 8776 } |
8777 | 8777 |
8778 } // namespace dart | 8778 } // namespace dart |
OLD | NEW |