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

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

Issue 1255063005: Constructor tear-off closures (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Skip tearoff test in analyzer and dart2js Created 5 years, 4 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
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 6178 matching lines...) Expand 10 before | Expand all | Expand 10 after
6189 } 6189 }
6190 if (!StaticBit::decode(kind_tag)) { 6190 if (!StaticBit::decode(kind_tag)) {
6191 return false; 6191 return false;
6192 } 6192 }
6193 RawClosureData* data = reinterpret_cast<RawClosureData*>(func->ptr()->data_); 6193 RawClosureData* data = reinterpret_cast<RawClosureData*>(func->ptr()->data_);
6194 RawFunction* parent_function = data->ptr()->parent_function_; 6194 RawFunction* parent_function = data->ptr()->parent_function_;
6195 return (parent_function->ptr()->data_ == reinterpret_cast<RawObject*>(func)); 6195 return (parent_function->ptr()->data_ == reinterpret_cast<RawObject*>(func));
6196 } 6196 }
6197 6197
6198 6198
6199 bool Function::IsConstructorClosureFunction() const {
6200 return IsClosureFunction() &&
6201 String::Handle(name()).StartsWith(Symbols::ConstructorClosurePrefix());
6202 }
6203
6204
6199 RawFunction* Function::New() { 6205 RawFunction* Function::New() {
6200 ASSERT(Object::function_class() != Class::null()); 6206 ASSERT(Object::function_class() != Class::null());
6201 RawObject* raw = Object::Allocate(Function::kClassId, 6207 RawObject* raw = Object::Allocate(Function::kClassId,
6202 Function::InstanceSize(), 6208 Function::InstanceSize(),
6203 Heap::kOld); 6209 Heap::kOld);
6204 return reinterpret_cast<RawFunction*>(raw); 6210 return reinterpret_cast<RawFunction*>(raw);
6205 } 6211 }
6206 6212
6207 6213
6208 RawFunction* Function::New(const String& name, 6214 RawFunction* Function::New(const String& name,
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
6496 pieces.Add(Symbols::RBrace()); 6502 pieces.Add(Symbols::RBrace());
6497 } 6503 }
6498 } 6504 }
6499 } 6505 }
6500 6506
6501 6507
6502 RawInstance* Function::ImplicitStaticClosure() const { 6508 RawInstance* Function::ImplicitStaticClosure() const {
6503 if (implicit_static_closure() == Instance::null()) { 6509 if (implicit_static_closure() == Instance::null()) {
6504 Isolate* isolate = Isolate::Current(); 6510 Isolate* isolate = Isolate::Current();
6505 ObjectStore* object_store = isolate->object_store(); 6511 ObjectStore* object_store = isolate->object_store();
6506 const Context& context = Context::Handle(isolate, 6512 const Context& context =
6507 object_store->empty_context()); 6513 Context::Handle(isolate, object_store->empty_context());
6508 Instance& closure = 6514 Instance& closure =
6509 Instance::Handle(isolate, Closure::New(*this, context, Heap::kOld)); 6515 Instance::Handle(isolate, Closure::New(*this, context, Heap::kOld));
6510 const char* error_str = NULL; 6516 const char* error_str = NULL;
6511 closure ^= closure.CheckAndCanonicalize(&error_str); 6517 closure ^= closure.CheckAndCanonicalize(&error_str);
6512 ASSERT(!closure.IsNull()); 6518 ASSERT(!closure.IsNull());
6513 set_implicit_static_closure(closure); 6519 set_implicit_static_closure(closure);
6514 } 6520 }
6515 return implicit_static_closure(); 6521 return implicit_static_closure();
6516 } 6522 }
6517 6523
(...skipping 14808 matching lines...) Expand 10 before | Expand all | Expand 10 after
21326 return tag_label.ToCString(); 21332 return tag_label.ToCString();
21327 } 21333 }
21328 21334
21329 21335
21330 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21336 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21331 Instance::PrintJSONImpl(stream, ref); 21337 Instance::PrintJSONImpl(stream, ref);
21332 } 21338 }
21333 21339
21334 21340
21335 } // namespace dart 21341 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698