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

Side by Side Diff: runtime/vm/dart_api_state.h

Issue 9347040: Add API function Dart_ZoneAllocate (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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/dart_api_impl_test.cc ('k') | runtime/vm/native_message_handler.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 #ifndef VM_DART_API_STATE_H_ 5 #ifndef VM_DART_API_STATE_H_
6 #define VM_DART_API_STATE_H_ 6 #define VM_DART_API_STATE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "platform/thread.h" 10 #include "platform/thread.h"
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 ~ApiNativeScope() { 530 ~ApiNativeScope() {
531 ASSERT(Current() == this); 531 ASSERT(Current() == this);
532 Thread::SetThreadLocal(Api::api_native_key_, NULL); 532 Thread::SetThreadLocal(Api::api_native_key_, NULL);
533 } 533 }
534 534
535 static inline ApiNativeScope* Current() { 535 static inline ApiNativeScope* Current() {
536 return reinterpret_cast<ApiNativeScope*>( 536 return reinterpret_cast<ApiNativeScope*>(
537 Thread::GetThreadLocal(Api::api_native_key_)); 537 Thread::GetThreadLocal(Api::api_native_key_));
538 } 538 }
539 539
540 ApiZone* zone() { return &zone_; } 540 ApiZone& zone() { return zone_; }
Ivan Posva 2012/02/15 16:08:46 It should probably really stay as a ApiZone*. Mayb
Søren Gjesse 2012/02/15 16:42:03 Done.
541 541
542 private: 542 private:
543 ApiZone zone_; 543 ApiZone zone_;
544 ThreadLocalKey key_; 544 ThreadLocalKey key_;
545 }; 545 };
546 546
547 547
548 // Api growable arrays use a zone for allocation. The constructor 548 // Api growable arrays use a zone for allocation. The constructor
549 // picks the zone from the current isolate if in an isolate 549 // picks the zone from the current isolate if in an isolate
550 // environment. When outside an isolate environment it picks the zone 550 // environment. When outside an isolate environment it picks the zone
551 // from the current native scope. 551 // from the current native scope.
552 template<typename T> 552 template<typename T>
553 class ApiGrowableArray : public BaseGrowableArray<T, ValueObject> { 553 class ApiGrowableArray : public BaseGrowableArray<T, ValueObject> {
554 public: 554 public:
555 explicit ApiGrowableArray(int initial_capacity) 555 explicit ApiGrowableArray(int initial_capacity)
556 : BaseGrowableArray<T, ValueObject>( 556 : BaseGrowableArray<T, ValueObject>(
557 initial_capacity, 557 initial_capacity,
558 ApiNativeScope::Current()->zone()->GetBaseZone()) {} 558 ApiNativeScope::Current()->zone().GetBaseZone()) {}
559 ApiGrowableArray() 559 ApiGrowableArray()
560 : BaseGrowableArray<T, ValueObject>( 560 : BaseGrowableArray<T, ValueObject>(
561 ApiNativeScope::Current()->zone()->GetBaseZone()) {} 561 ApiNativeScope::Current()->zone().GetBaseZone()) {}
562 }; 562 };
563 563
564 564
565 } // namespace dart 565 } // namespace dart
566 566
567 #endif // VM_DART_API_STATE_H_ 567 #endif // VM_DART_API_STATE_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/native_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698