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

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

Issue 1220193009: Migrate most uses of Isolate::current_zone to Thread::zone. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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/service_test.cc ('k') | runtime/vm/snapshot_test.cc » ('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 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 const Class& clazz = Class::Handle(isolate(), cls); 2068 const Class& clazz = Class::Handle(isolate(), cls);
2069 const Function& errorFunc = Function::Handle(isolate(), func); 2069 const Function& errorFunc = Function::Handle(isolate(), func);
2070 ASSERT(!errorFunc.IsNull()); 2070 ASSERT(!errorFunc.IsNull());
2071 2071
2072 // All other closures are errors. 2072 // All other closures are errors.
2073 const char* format = "Illegal argument in isolate message" 2073 const char* format = "Illegal argument in isolate message"
2074 " : (object is a closure - %s %s)"; 2074 " : (object is a closure - %s %s)";
2075 UnmarkAll(); // Unmark objects now as we are about to print stuff. 2075 UnmarkAll(); // Unmark objects now as we are about to print stuff.
2076 intptr_t len = OS::SNPrint(NULL, 0, format, 2076 intptr_t len = OS::SNPrint(NULL, 0, format,
2077 clazz.ToCString(), errorFunc.ToCString()) + 1; 2077 clazz.ToCString(), errorFunc.ToCString()) + 1;
2078 char* chars = isolate()->current_zone()->Alloc<char>(len); 2078 char* chars = Thread::Current()->zone()->Alloc<char>(len);
2079 OS::SNPrint(chars, len, format, clazz.ToCString(), errorFunc.ToCString()); 2079 OS::SNPrint(chars, len, format, clazz.ToCString(), errorFunc.ToCString());
2080 SetWriteException(Exceptions::kArgument, chars); 2080 SetWriteException(Exceptions::kArgument, chars);
2081 } 2081 }
2082 return Function::null(); 2082 return Function::null();
2083 } 2083 }
2084 2084
2085 2085
2086 RawClass* SnapshotWriter::GetFunctionOwner(RawFunction* func) { 2086 RawClass* SnapshotWriter::GetFunctionOwner(RawFunction* func) {
2087 RawObject* owner = func->ptr()->owner_; 2087 RawObject* owner = func->ptr()->owner_;
2088 uword tags = GetObjectTags(owner); 2088 uword tags = GetObjectTags(owner);
2089 intptr_t class_id = RawObject::ClassIdTag::decode(tags); 2089 intptr_t class_id = RawObject::ClassIdTag::decode(tags);
2090 if (class_id == kClassCid) { 2090 if (class_id == kClassCid) {
2091 return reinterpret_cast<RawClass*>(owner); 2091 return reinterpret_cast<RawClass*>(owner);
2092 } 2092 }
2093 ASSERT(class_id == kPatchClassCid); 2093 ASSERT(class_id == kPatchClassCid);
2094 return reinterpret_cast<RawPatchClass*>(owner)->ptr()->patched_class_; 2094 return reinterpret_cast<RawPatchClass*>(owner)->ptr()->patched_class_;
2095 } 2095 }
2096 2096
2097 2097
2098 void SnapshotWriter::CheckForNativeFields(RawClass* cls) { 2098 void SnapshotWriter::CheckForNativeFields(RawClass* cls) {
2099 if (cls->ptr()->num_native_fields_ != 0) { 2099 if (cls->ptr()->num_native_fields_ != 0) {
2100 // We do not allow objects with native fields in an isolate message. 2100 // We do not allow objects with native fields in an isolate message.
2101 HANDLESCOPE(isolate()); 2101 HANDLESCOPE(isolate());
2102 const char* format = "Illegal argument in isolate message" 2102 const char* format = "Illegal argument in isolate message"
2103 " : (object extends NativeWrapper - %s)"; 2103 " : (object extends NativeWrapper - %s)";
2104 UnmarkAll(); // Unmark objects now as we are about to print stuff. 2104 UnmarkAll(); // Unmark objects now as we are about to print stuff.
2105 const Class& clazz = Class::Handle(isolate(), cls); 2105 const Class& clazz = Class::Handle(isolate(), cls);
2106 intptr_t len = OS::SNPrint(NULL, 0, format, clazz.ToCString()) + 1; 2106 intptr_t len = OS::SNPrint(NULL, 0, format, clazz.ToCString()) + 1;
2107 char* chars = isolate()->current_zone()->Alloc<char>(len); 2107 char* chars = Thread::Current()->zone()->Alloc<char>(len);
2108 OS::SNPrint(chars, len, format, clazz.ToCString()); 2108 OS::SNPrint(chars, len, format, clazz.ToCString());
2109 SetWriteException(Exceptions::kArgument, chars); 2109 SetWriteException(Exceptions::kArgument, chars);
2110 } 2110 }
2111 } 2111 }
2112 2112
2113 2113
2114 void SnapshotWriter::SetWriteException(Exceptions::ExceptionType type, 2114 void SnapshotWriter::SetWriteException(Exceptions::ExceptionType type,
2115 const char* msg) { 2115 const char* msg) {
2116 set_exception_type(type); 2116 set_exception_type(type);
2117 set_exception_msg(msg); 2117 set_exception_msg(msg);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 NoSafepointScope no_safepoint; 2341 NoSafepointScope no_safepoint;
2342 WriteObject(obj.raw()); 2342 WriteObject(obj.raw());
2343 UnmarkAll(); 2343 UnmarkAll();
2344 } else { 2344 } else {
2345 ThrowException(exception_type(), exception_msg()); 2345 ThrowException(exception_type(), exception_msg());
2346 } 2346 }
2347 } 2347 }
2348 2348
2349 2349
2350 } // namespace dart 2350 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/service_test.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698