Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: runtime/vm/snapshot.cc

Issue 2005723004: Fraction class prototype and test (not to be committed). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 void SnapshotReader::SetReadException(const char* msg) { 348 void SnapshotReader::SetReadException(const char* msg) {
349 const String& error_str = String::Handle(zone(), String::New(msg)); 349 const String& error_str = String::Handle(zone(), String::New(msg));
350 const Array& args = Array::Handle(zone(), Array::New(1)); 350 const Array& args = Array::Handle(zone(), Array::New(1));
351 args.SetAt(0, error_str); 351 args.SetAt(0, error_str);
352 Object& result = Object::Handle(zone()); 352 Object& result = Object::Handle(zone());
353 const Library& library = Library::Handle(zone(), Library::CoreLibrary()); 353 const Library& library = Library::Handle(zone(), Library::CoreLibrary());
354 result = DartLibraryCalls::InstanceCreate(library, 354 result = DartLibraryCalls::InstanceCreate(library,
355 Symbols::ArgumentError(), 355 Symbols::ArgumentError(),
356 Symbols::Dot(), 356 Symbols::Dot(),
357 false, // Not a factory.
357 args); 358 args);
358 const Stacktrace& stacktrace = Stacktrace::Handle(zone()); 359 const Stacktrace& stacktrace = Stacktrace::Handle(zone());
359 const UnhandledException& error = UnhandledException::Handle( 360 const UnhandledException& error = UnhandledException::Handle(
360 zone(), UnhandledException::New(Instance::Cast(result), stacktrace)); 361 zone(), UnhandledException::New(Instance::Cast(result), stacktrace));
361 thread()->long_jump_base()->Jump(1, error); 362 thread()->long_jump_base()->Jump(1, error);
362 } 363 }
363 364
364 365
365 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const { 366 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const {
366 return Object::vm_isolate_snapshot_object_table().At(index); 367 return Object::vm_isolate_snapshot_object_table().At(index);
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 ASSERT_NO_SAFEPOINT_SCOPE(); 884 ASSERT_NO_SAFEPOINT_SCOPE();
884 const intptr_t lengthInBytes = len * TypedData::ElementSizeInBytes(class_id); 885 const intptr_t lengthInBytes = len * TypedData::ElementSizeInBytes(class_id);
885 RawTypedData* obj = reinterpret_cast<RawTypedData*>( 886 RawTypedData* obj = reinterpret_cast<RawTypedData*>(
886 AllocateUninitialized(class_id, TypedData::InstanceSize(lengthInBytes))); 887 AllocateUninitialized(class_id, TypedData::InstanceSize(lengthInBytes)));
887 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(len)); 888 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(len));
888 return obj; 889 return obj;
889 } 890 }
890 891
891 892
892 #define ALLOC_NEW_OBJECT(type) \ 893 #define ALLOC_NEW_OBJECT(type) \
893 ASSERT(Snapshot::IsFull(kind_)); \ 894 ASSERT(Snapshot::IsFull(kind_)); \
894 ASSERT_NO_SAFEPOINT_SCOPE(); \ 895 ASSERT_NO_SAFEPOINT_SCOPE(); \
895 return reinterpret_cast<Raw##type*>( \ 896 return reinterpret_cast<Raw##type*>( \
896 AllocateUninitialized(k##type##Cid, type::InstanceSize())); \ 897 AllocateUninitialized(k##type##Cid, type::InstanceSize())); \
897 898
898 899
899 RawBigint* SnapshotReader::NewBigint() { 900 RawBigint* SnapshotReader::NewBigint() {
900 ALLOC_NEW_OBJECT(Bigint); 901 ALLOC_NEW_OBJECT(Bigint);
901 } 902 }
902 903
903 904
905 RawFraction* SnapshotReader::NewFraction() {
906 ALLOC_NEW_OBJECT(Fraction);
907 }
908
909
904 RawUnresolvedClass* SnapshotReader::NewUnresolvedClass() { 910 RawUnresolvedClass* SnapshotReader::NewUnresolvedClass() {
905 ALLOC_NEW_OBJECT(UnresolvedClass); 911 ALLOC_NEW_OBJECT(UnresolvedClass);
906 } 912 }
907 913
908 914
909 RawType* SnapshotReader::NewType() { 915 RawType* SnapshotReader::NewType() {
910 ALLOC_NEW_OBJECT(Type); 916 ALLOC_NEW_OBJECT(Type);
911 } 917 }
912 918
913 919
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 return raw->ptr()->tags_; 1695 return raw->ptr()->tags_;
1690 } 1696 }
1691 1697
1692 1698
1693 #define VM_OBJECT_CLASS_LIST(V) \ 1699 #define VM_OBJECT_CLASS_LIST(V) \
1694 V(OneByteString) \ 1700 V(OneByteString) \
1695 V(TwoByteString) \ 1701 V(TwoByteString) \
1696 V(Mint) \ 1702 V(Mint) \
1697 V(Bigint) \ 1703 V(Bigint) \
1698 V(Double) \ 1704 V(Double) \
1705 V(Fraction) \
1699 V(ImmutableArray) \ 1706 V(ImmutableArray) \
1700 1707
1701 #define VM_OBJECT_WRITE(clazz) \ 1708 #define VM_OBJECT_WRITE(clazz) \
1702 case clazz::kClassId: { \ 1709 case clazz::kClassId: { \
1703 object_id = forward_list_->AddObject(zone(), rawobj, kIsSerialized); \ 1710 object_id = forward_list_->AddObject(zone(), rawobj, kIsSerialized); \
1704 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(rawobj); \ 1711 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(rawobj); \
1705 raw_obj->WriteTo(this, object_id, kind(), false); \ 1712 raw_obj->WriteTo(this, object_id, kind(), false); \
1706 return true; \ 1713 return true; \
1707 } \ 1714 } \
1708 1715
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 if (setjmp(*jump.Set()) == 0) { 2440 if (setjmp(*jump.Set()) == 0) {
2434 NoSafepointScope no_safepoint; 2441 NoSafepointScope no_safepoint;
2435 WriteObject(obj.raw()); 2442 WriteObject(obj.raw());
2436 } else { 2443 } else {
2437 ThrowException(exception_type(), exception_msg()); 2444 ThrowException(exception_type(), exception_msg());
2438 } 2445 }
2439 } 2446 }
2440 2447
2441 2448
2442 } // namespace dart 2449 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698