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

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

Issue 10897014: Performance improvement for the Dart VM runtime method (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 } 1521 }
1522 1522
1523 1523
1524 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) { 1524 DART_EXPORT bool Dart_IsExternalString(Dart_Handle object) {
1525 return RawObject::IsExternalStringClassId(Api::ClassId(object)); 1525 return RawObject::IsExternalStringClassId(Api::ClassId(object));
1526 } 1526 }
1527 1527
1528 1528
1529 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object, 1529 DART_EXPORT Dart_Handle Dart_ExternalStringGetPeer(Dart_Handle object,
1530 void** peer) { 1530 void** peer) {
1531 Isolate* isolate = Isolate::Current();
1532 DARTSCOPE(isolate);
1533 const String& str = Api::UnwrapStringHandle(isolate, object);
1534 if (str.IsNull()) {
1535 RETURN_TYPE_ERROR(isolate, object, String);
1536 }
1537 if (!str.IsExternal()) {
1538 return
1539 Api::NewError("%s expects argument 'object' to be an external String.",
1540 CURRENT_FUNC);
1541 }
1542 if (peer == NULL) { 1531 if (peer == NULL) {
1543 RETURN_NULL_ERROR(peer); 1532 RETURN_NULL_ERROR(peer);
1544 } 1533 }
1545 *peer = str.GetPeer(); 1534 // NoGCScope no_gc_scope;
1546 return Api::Success(isolate); 1535 intptr_t class_id = Api::ClassId(object);
1536 RawObject* raw_obj = Api::UnwrapHandle(object);
1537 switch (class_id) {
1538 case kExternalOneByteStringCid: {
1539 RawExternalOneByteString* raw_string =
1540 reinterpret_cast<RawExternalOneByteString*>(raw_obj)->ptr();
1541 ExternalStringData<uint8_t>* data = raw_string->external_data_;
1542 *peer = data->peer();
Ivan Posva 2012/08/29 05:59:30 How about this? RawExternalOneByteString* raw_stri
1543 break;
1544 }
1545 case kExternalTwoByteStringCid: {
1546 RawExternalTwoByteString* raw_string =
1547 reinterpret_cast<RawExternalTwoByteString*>(raw_obj)->ptr();
1548 ExternalStringData<uint16_t>* data = raw_string->external_data_;
1549 *peer = data->peer();
1550 break;
1551 }
1552 case kExternalFourByteStringCid: {
1553 RawExternalFourByteString* raw_string =
1554 reinterpret_cast<RawExternalFourByteString*>(raw_obj)->ptr();
1555 ExternalStringData<uint32_t>* data = raw_string->external_data_;
1556 *peer = data->peer();
1557 break;
1558 }
1559 default: {
1560 // It's not an external string, return appropriate error.
1561 if (!RawObject::IsStringClassId(class_id)) {
1562 RETURN_TYPE_ERROR(Isolate::Current(), object, String);
1563 } else {
1564 return
1565 Api::NewError(
1566 "%s expects argument 'object' to be an external String.",
1567 CURRENT_FUNC);
1568 }
1569 }
1570 }
1571 return Api::Success(Isolate::Current());
1547 } 1572 }
1548 1573
1549 1574
1550 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints, 1575 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints,
1551 intptr_t length, 1576 intptr_t length,
1552 void* peer, 1577 void* peer,
1553 Dart_PeerFinalizer callback) { 1578 Dart_PeerFinalizer callback) {
1554 Isolate* isolate = Isolate::Current(); 1579 Isolate* isolate = Isolate::Current();
1555 DARTSCOPE(isolate); 1580 DARTSCOPE(isolate);
1556 if (codepoints == NULL && length != 0) { 1581 if (codepoints == NULL && length != 0) {
(...skipping 2574 matching lines...) Expand 10 before | Expand all | Expand 10 after
4131 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4156 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4132 Dart::set_perf_events_writer(function); 4157 Dart::set_perf_events_writer(function);
4133 } 4158 }
4134 4159
4135 4160
4136 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4161 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4137 Dart::set_flow_graph_writer(function); 4162 Dart::set_flow_graph_writer(function);
4138 } 4163 }
4139 4164
4140 } // namespace dart 4165 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698