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

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

Issue 982723002: Fix for issue 20992 - Allow sending static/top-level functions to other isolates which are spawned … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 6066 matching lines...) Expand 10 before | Expand all | Expand 10 after
6077 6077
6078 bool Function::IsImplicitClosureFunction() const { 6078 bool Function::IsImplicitClosureFunction() const {
6079 if (!IsClosureFunction()) { 6079 if (!IsClosureFunction()) {
6080 return false; 6080 return false;
6081 } 6081 }
6082 const Function& parent = Function::Handle(parent_function()); 6082 const Function& parent = Function::Handle(parent_function());
6083 return (parent.implicit_closure_function() == raw()); 6083 return (parent.implicit_closure_function() == raw());
6084 } 6084 }
6085 6085
6086 6086
6087 bool Function::IsImplicitStaticClosureFunction(RawFunction* func) {
6088 NoGCScope no_gc;
6089 uint32_t kind_tag = func->ptr()->kind_tag_;
6090 if (KindBits::decode(kind_tag) != RawFunction::kClosureFunction) {
6091 return false;
6092 }
6093 if (!StaticBit::decode(kind_tag)) {
6094 return false;
6095 }
6096 RawClosureData* data = reinterpret_cast<RawClosureData*>(func->ptr()->data_);
6097 RawFunction* parent_function = data->ptr()->parent_function_;
6098 return (parent_function->ptr()->data_ == reinterpret_cast<RawObject*>(func));
6099 }
6100
6101
6087 RawFunction* Function::New() { 6102 RawFunction* Function::New() {
6088 ASSERT(Object::function_class() != Class::null()); 6103 ASSERT(Object::function_class() != Class::null());
6089 RawObject* raw = Object::Allocate(Function::kClassId, 6104 RawObject* raw = Object::Allocate(Function::kClassId,
6090 Function::InstanceSize(), 6105 Function::InstanceSize(),
6091 Heap::kOld); 6106 Heap::kOld);
6092 return reinterpret_cast<RawFunction*>(raw); 6107 return reinterpret_cast<RawFunction*>(raw);
6093 } 6108 }
6094 6109
6095 6110
6096 RawFunction* Function::New(const String& name, 6111 RawFunction* Function::New(const String& name,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
6376 pieces.Add(Symbols::RBracket()); 6391 pieces.Add(Symbols::RBracket());
6377 } else { 6392 } else {
6378 pieces.Add(Symbols::RBrace()); 6393 pieces.Add(Symbols::RBrace());
6379 } 6394 }
6380 } 6395 }
6381 } 6396 }
6382 6397
6383 6398
6384 RawInstance* Function::ImplicitStaticClosure() const { 6399 RawInstance* Function::ImplicitStaticClosure() const {
6385 if (implicit_static_closure() == Instance::null()) { 6400 if (implicit_static_closure() == Instance::null()) {
6386 ObjectStore* object_store = Isolate::Current()->object_store(); 6401 Isolate* isolate = Isolate::Current();
6387 const Context& context = Context::Handle(object_store->empty_context()); 6402 ObjectStore* object_store = isolate->object_store();
6388 const Instance& closure = 6403 const Context& context = Context::Handle(isolate,
6389 Instance::Handle(Closure::New(*this, context, Heap::kOld)); 6404 object_store->empty_context());
6405 Instance& closure =
6406 Instance::Handle(isolate, Closure::New(*this, context, Heap::kOld));
6407 const char* error_str = NULL;
6408 closure ^= closure.CheckAndCanonicalize(&error_str);
6409 ASSERT(!closure.IsNull());
6390 set_implicit_static_closure(closure); 6410 set_implicit_static_closure(closure);
6391 } 6411 }
6392 return implicit_static_closure(); 6412 return implicit_static_closure();
6393 } 6413 }
6394 6414
6395 6415
6396 RawString* Function::BuildSignature(bool instantiate, 6416 RawString* Function::BuildSignature(bool instantiate,
6397 NameVisibility name_visibility, 6417 NameVisibility name_visibility,
6398 const TypeArguments& instantiator) const { 6418 const TypeArguments& instantiator) const {
6399 const GrowableObjectArray& pieces = 6419 const GrowableObjectArray& pieces =
(...skipping 14293 matching lines...) Expand 10 before | Expand all | Expand 10 after
20693 return tag_label.ToCString(); 20713 return tag_label.ToCString();
20694 } 20714 }
20695 20715
20696 20716
20697 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20717 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20698 Instance::PrintJSONImpl(stream, ref); 20718 Instance::PrintJSONImpl(stream, ref);
20699 } 20719 }
20700 20720
20701 20721
20702 } // namespace dart 20722 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698