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

Side by Side Diff: runtime/bin/dartutils.cc

Issue 12093071: - Change the layout of external typed array objects to avoid the extra indirection when accessing e… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/bin/dartutils.h ('k') | runtime/bin/io_buffer.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 "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/extensions.h" 7 #include "bin/extensions.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/file.h" 9 #include "bin/file.h"
10 #include "bin/io_buffer.h" 10 #include "bin/io_buffer.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 657
658 658
659 Dart_CObject* CObject::NewUint8Array(int length) { 659 Dart_CObject* CObject::NewUint8Array(int length) {
660 Dart_CObject* cobject = New(Dart_CObject::kUint8Array, length); 660 Dart_CObject* cobject = New(Dart_CObject::kUint8Array, length);
661 cobject->value.as_byte_array.length = length; 661 cobject->value.as_byte_array.length = length;
662 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1); 662 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1);
663 return cobject; 663 return cobject;
664 } 664 }
665 665
666 666
667 Dart_CObject* CObject::NewExternalUint8Array(int64_t length, 667 Dart_CObject* CObject::NewExternalUint8Array(
668 uint8_t* data, 668 int64_t length, uint8_t* data, void* peer,
669 void* peer, 669 Dart_WeakPersistentHandleFinalizer callback) {
670 Dart_PeerFinalizer callback) {
671 Dart_CObject* cobject = New(Dart_CObject::kExternalUint8Array); 670 Dart_CObject* cobject = New(Dart_CObject::kExternalUint8Array);
672 cobject->value.as_external_byte_array.length = length; 671 cobject->value.as_external_byte_array.length = length;
673 cobject->value.as_external_byte_array.data = data; 672 cobject->value.as_external_byte_array.data = data;
674 cobject->value.as_external_byte_array.peer = peer; 673 cobject->value.as_external_byte_array.peer = peer;
675 cobject->value.as_external_byte_array.callback = callback; 674 cobject->value.as_external_byte_array.callback = callback;
676 return cobject; 675 return cobject;
677 } 676 }
678 677
679 678
680 Dart_CObject* CObject::NewIOBuffer(int64_t length) { 679 Dart_CObject* CObject::NewIOBuffer(int64_t length) {
681 uint8_t* data = IOBuffer::Allocate(length); 680 uint8_t* data = IOBuffer::Allocate(length);
682 return NewExternalUint8Array(length, data, data, IOBuffer::Free); 681 return NewExternalUint8Array(length, data, data, IOBuffer::Finalizer);
683 } 682 }
684 683
685 684
686 void CObject::FreeIOBufferData(Dart_CObject* cobject) { 685 void CObject::FreeIOBufferData(Dart_CObject* cobject) {
687 ASSERT(cobject->type == Dart_CObject::kExternalUint8Array); 686 ASSERT(cobject->type == Dart_CObject::kExternalUint8Array);
688 cobject->value.as_external_byte_array.callback( 687 cobject->value.as_external_byte_array.callback(
689 cobject->value.as_external_byte_array.peer); 688 NULL, cobject->value.as_external_byte_array.peer);
690 cobject->value.as_external_byte_array.data = NULL; 689 cobject->value.as_external_byte_array.data = NULL;
691 } 690 }
692 691
693 692
694 static int kArgumentError = 1; 693 static int kArgumentError = 1;
695 static int kOSError = 2; 694 static int kOSError = 2;
696 static int kFileClosedError = 3; 695 static int kFileClosedError = 3;
697 696
698 697
699 CObject* CObject::IllegalArgumentError() { 698 CObject* CObject::IllegalArgumentError() {
(...skipping 17 matching lines...) Expand all
717 716
718 CObject* CObject::NewOSError(OSError* os_error) { 717 CObject* CObject::NewOSError(OSError* os_error) {
719 CObject* error_message = 718 CObject* error_message =
720 new CObjectString(CObject::NewString(os_error->message())); 719 new CObjectString(CObject::NewString(os_error->message()));
721 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 720 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
722 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 721 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
723 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 722 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
724 result->SetAt(2, error_message); 723 result->SetAt(2, error_message);
725 return result; 724 return result;
726 } 725 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/io_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698