Chromium Code Reviews| Index: runtime/vm/object.cc |
| =================================================================== |
| --- runtime/vm/object.cc (revision 35191) |
| +++ runtime/vm/object.cc (working copy) |
| @@ -891,10 +891,10 @@ |
| TIMERSCOPE(isolate, time_bootstrap); |
| ObjectStore* object_store = isolate->object_store(); |
| - Class& cls = Class::Handle(); |
| - Type& type = Type::Handle(); |
| - Array& array = Array::Handle(); |
| - Library& lib = Library::Handle(); |
| + Class& cls = Class::Handle(isolate); |
| + Type& type = Type::Handle(isolate); |
| + Array& array = Array::Handle(isolate); |
| + Library& lib = Library::Handle(isolate); |
| // All RawArray fields will be initialized to an empty array, therefore |
| // initialize array class first. |
| @@ -922,7 +922,8 @@ |
| // Last element contains the count of used slots. |
| const intptr_t kInitialCanonicalTypeArgumentsSize = 4; |
| array = Array::New(kInitialCanonicalTypeArgumentsSize + 1); |
| - array.SetAt(kInitialCanonicalTypeArgumentsSize, Smi::Handle(Smi::New(0))); |
| + array.SetAt(kInitialCanonicalTypeArgumentsSize, |
| + Smi::Handle(isolate, Smi::New(0))); |
| object_store->set_canonical_type_arguments(array); |
| // Setup type class early in the process. |
| @@ -956,34 +957,34 @@ |
| Symbols::SetupSymbolTable(isolate); |
| // Set up the libraries array before initializing the core library. |
| - const GrowableObjectArray& libraries = |
| - GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld)); |
| + const GrowableObjectArray& libraries = GrowableObjectArray::Handle( |
| + isolate, GrowableObjectArray::New(Heap::kOld)); |
| object_store->set_libraries(libraries); |
| // Pre-register the core library. |
| Library::InitCoreLibrary(isolate); |
| // Basic infrastructure has been setup, initialize the class dictionary. |
| - Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| + const Library& core_lib = Library::Handle(isolate, Library::CoreLibrary()); |
| ASSERT(!core_lib.IsNull()); |
| const GrowableObjectArray& pending_classes = |
| - GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| + GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); |
| object_store->set_pending_classes(pending_classes); |
| - Context& context = Context::Handle(Context::New(0, Heap::kOld)); |
| + Context& context = Context::Handle(isolate, Context::New(0, Heap::kOld)); |
| object_store->set_empty_context(context); |
| // Now that the symbol table is initialized and that the core dictionary as |
| // well as the core implementation dictionary have been setup, preallocate |
| // remaining classes and register them by name in the dictionaries. |
| - String& name = String::Handle(); |
| + String& name = String::Handle(isolate); |
| cls = object_store->array_class(); // Was allocated above. |
| RegisterPrivateClass(cls, Symbols::_List(), core_lib); |
| pending_classes.Add(cls); |
| // We cannot use NewNonParameterizedType(cls), because Array is parameterized. |
| - type ^= Type::New(Object::Handle(cls.raw()), |
| - TypeArguments::Handle(), |
| + type ^= Type::New(Object::Handle(isolate, cls.raw()), |
| + TypeArguments::Handle(isolate), |
| Scanner::kNoSourcePos); |
| type.SetIsFinalized(); |
| type ^= type.Canonicalize(); |
| @@ -1021,6 +1022,34 @@ |
| RegisterPrivateClass(cls, Symbols::ExternalTwoByteString(), core_lib); |
| pending_classes.Add(cls); |
| + // Pre-register the isolate library so the native class implementations |
| + // can be hooked up before compiling it. |
| + Library& isolate_lib = |
| + Library::Handle(isolate, Library::LookupLibrary(Symbols::DartIsolate())); |
| + if (isolate_lib.IsNull()) { |
| + isolate_lib = Library::NewLibraryHelper(Symbols::DartIsolate(), true); |
| + isolate_lib.Register(); |
| + isolate->object_store()->set_bootstrap_library(ObjectStore::kIsolate, |
| + isolate_lib); |
| + } |
| + ASSERT(!isolate_lib.IsNull()); |
| + ASSERT(isolate_lib.raw() == Library::IsolateLibrary()); |
| + |
| + cls = Class::New<Capability>(); |
| + object_store->set_capability_class(cls); |
| + RegisterPrivateClass(cls, Symbols::_CapabilityImpl(), isolate_lib); |
| + pending_classes.Add(cls); |
| + |
| + cls = Class::New<ReceivePort>(); |
| + object_store->set_receive_port_class(cls); |
| + RegisterPrivateClass(cls, Symbols::_RawReceivePortImpl(), isolate_lib); |
| + pending_classes.Add(cls); |
| + |
| + cls = Class::New<SendPort>(); |
| + object_store->set_send_port_class(cls); |
| + RegisterPrivateClass(cls, Symbols::_SendPortImpl(), isolate_lib); |
| + pending_classes.Add(cls); |
| + |
| cls = Class::New<Stacktrace>(); |
| object_store->set_stacktrace_class(cls); |
| RegisterClass(cls, Symbols::StackTrace(), core_lib); |
| @@ -1443,6 +1472,15 @@ |
| cls = Class::New<Instance>(kNullCid); |
| object_store->set_null_class(cls); |
| + cls = Class::New<Capability>(); |
| + object_store->set_capability_class(cls); |
| + |
| + cls = Class::New<ReceivePort>(); |
| + object_store->set_receive_port_class(cls); |
| + |
| + cls = Class::New<SendPort>(); |
| + object_store->set_send_port_class(cls); |
| + |
| cls = Class::New<Stacktrace>(); |
| object_store->set_stacktrace_class(cls); |
| @@ -14697,7 +14735,7 @@ |
| if (!silent && |
| FLAG_throw_on_javascript_int_overflow && |
| !IsJavascriptInt(value)) { |
| - const Integer &i = Integer::Handle(Mint::New(value)); |
| + const Integer& i = Integer::Handle(Mint::New(value)); |
| ThrowJavascriptIntegerOverflow(i); |
| } |
| return Mint::New(value, space); |
| @@ -17860,7 +17898,82 @@ |
| } |
| +RawCapability* Capability::New(uint64_t id, Heap::Space space) { |
| + Capability& result = Capability::Handle(); |
| + { |
| + RawObject* raw = Object::Allocate(Capability::kClassId, |
| + Capability::InstanceSize(), |
| + space); |
| + NoGCScope no_gc; |
| + result ^= raw; |
| + } |
| + result.raw_ptr()->id_ = id; |
| + return result.raw(); |
| +} |
| + |
| +const char* Capability::ToCString() const { |
| + return "Capability"; |
|
turnidge
2014/04/22 18:40:45
Consider adding Id() to the ToCString, here and be
Ivan Posva
2014/04/22 21:28:30
Not printing it on purpose.
|
| +} |
| + |
| + |
| +void Capability::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| + Instance::PrintToJSONStream(stream, ref); |
| +} |
| + |
| + |
| +RawReceivePort* ReceivePort::New(Dart_Port id, Heap::Space space) { |
| + Isolate* isolate = Isolate::Current(); |
| + const SendPort& send_port = SendPort::Handle(isolate, SendPort::New(id)); |
| + |
| + ReceivePort& result = ReceivePort::Handle(isolate); |
| + { |
| + RawObject* raw = Object::Allocate(ReceivePort::kClassId, |
| + ReceivePort::InstanceSize(), |
| + space); |
| + NoGCScope no_gc; |
| + result ^= raw; |
| + } |
| + result.raw_ptr()->send_port_ = send_port.raw(); |
|
siva
2014/04/23 00:20:31
I think this line should also move inside the NoGC
Ivan Posva
2014/04/23 19:43:35
Done.
|
| + PortMap::SetLive(id); |
| + return result.raw(); |
| +} |
| + |
| + |
| +const char* ReceivePort::ToCString() const { |
| + return "ReceivePort"; |
|
Cutch
2014/04/22 20:15:22
Include the port id here and in SendPort::ToCStrin
Ivan Posva
2014/04/22 21:28:30
Not printing it on purpose.
|
| +} |
| + |
| + |
| +void ReceivePort::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| + Instance::PrintToJSONStream(stream, ref); |
| +} |
| + |
| + |
| +RawSendPort* SendPort::New(Dart_Port id, Heap::Space space) { |
| + SendPort& result = SendPort::Handle(); |
| + { |
| + RawObject* raw = Object::Allocate(SendPort::kClassId, |
| + SendPort::InstanceSize(), |
| + space); |
| + NoGCScope no_gc; |
| + result ^= raw; |
| + } |
| + result.raw_ptr()->id_ = id; |
|
siva
2014/04/23 00:20:31
Ditto comment about this line moving into the scop
|
| + return result.raw(); |
| +} |
| + |
| + |
| +const char* SendPort::ToCString() const { |
| + return "SendPort"; |
| +} |
| + |
| + |
| +void SendPort::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| + Instance::PrintToJSONStream(stream, ref); |
| +} |
| + |
| + |
| const char* Closure::ToCString(const Instance& closure) { |
| const Function& fun = Function::Handle(Closure::function(closure)); |
| const bool is_implicit_closure = fun.IsImplicitClosureFunction(); |