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/snapshot.h" | 5 #include "vm/snapshot.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 for (RawObject** current = first; current <= last; current++) { | 1901 for (RawObject** current = first; current <= last; current++) { |
1902 RawObject* raw_obj = *current; | 1902 RawObject* raw_obj = *current; |
1903 writer_->WriteObjectImpl(raw_obj, as_references_); | 1903 writer_->WriteObjectImpl(raw_obj, as_references_); |
1904 } | 1904 } |
1905 } | 1905 } |
1906 | 1906 |
1907 | 1907 |
1908 MessageWriter::MessageWriter(uint8_t** buffer, | 1908 MessageWriter::MessageWriter(uint8_t** buffer, |
1909 ReAlloc alloc, | 1909 ReAlloc alloc, |
1910 DeAlloc dealloc, | 1910 DeAlloc dealloc, |
1911 bool can_send_any_object) | 1911 bool can_send_any_object, |
| 1912 intptr_t* buffer_len) |
1912 : SnapshotWriter(Thread::Current(), | 1913 : SnapshotWriter(Thread::Current(), |
1913 Snapshot::kMessage, | 1914 Snapshot::kMessage, |
1914 buffer, | 1915 buffer, |
1915 alloc, | 1916 alloc, |
1916 dealloc, | 1917 dealloc, |
1917 kInitialSize, | 1918 kInitialSize, |
1918 &forward_list_, | 1919 &forward_list_, |
1919 can_send_any_object), | 1920 can_send_any_object), |
1920 forward_list_(thread(), kMaxPredefinedObjectIds) { | 1921 forward_list_(thread(), kMaxPredefinedObjectIds), |
| 1922 buffer_len_(buffer_len) { |
1921 ASSERT(buffer != NULL); | 1923 ASSERT(buffer != NULL); |
1922 ASSERT(alloc != NULL); | 1924 ASSERT(alloc != NULL); |
1923 } | 1925 } |
1924 | 1926 |
1925 | 1927 |
1926 void MessageWriter::WriteMessage(const Object& obj) { | 1928 void MessageWriter::WriteMessage(const Object& obj) { |
1927 ASSERT(kind() == Snapshot::kMessage); | 1929 ASSERT(kind() == Snapshot::kMessage); |
1928 ASSERT(isolate() != NULL); | 1930 ASSERT(isolate() != NULL); |
1929 | 1931 |
1930 // Setup for long jump in case there is an exception while writing | 1932 // Setup for long jump in case there is an exception while writing |
1931 // the message. | 1933 // the message. |
1932 LongJumpScope jump; | 1934 LongJumpScope jump; |
1933 if (setjmp(*jump.Set()) == 0) { | 1935 if (setjmp(*jump.Set()) == 0) { |
1934 NoSafepointScope no_safepoint; | 1936 NoSafepointScope no_safepoint; |
1935 WriteObject(obj.raw()); | 1937 WriteObject(obj.raw()); |
| 1938 if (buffer_len_ != NULL) { |
| 1939 *buffer_len_ = BytesWritten(); |
| 1940 } |
1936 } else { | 1941 } else { |
1937 FreeBuffer(); | 1942 FreeBuffer(); |
1938 ThrowException(exception_type(), exception_msg()); | 1943 ThrowException(exception_type(), exception_msg()); |
1939 } | 1944 } |
1940 } | 1945 } |
1941 | 1946 |
1942 | 1947 |
1943 } // namespace dart | 1948 } // namespace dart |
OLD | NEW |