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

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

Issue 10891036: Reworked previous CL (ExternalStringGetPeer speed up) to avoid the (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
« no previous file with comments | « no previous file | runtime/vm/raw_object.h » ('j') | runtime/vm/raw_object.h » ('J')
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 "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 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 intptr_t class_id = Api::ClassId(object); 1531 intptr_t class_id = Api::ClassId(object);
1532 if (peer == NULL) { 1532 if (peer == NULL) {
1533 RETURN_NULL_ERROR(peer); 1533 RETURN_NULL_ERROR(peer);
1534 } else { 1534 } else {
1535 NoGCScope no_gc_scope; 1535 NoGCScope no_gc_scope;
1536 RawObject* raw_obj = Api::UnwrapHandle(object); 1536 uword raw_addr = RawObject::ToAddr(Api::UnwrapHandle(object));
1537 switch (class_id) { 1537 switch (class_id) {
1538 case kExternalOneByteStringCid: { 1538 case kExternalOneByteStringCid: {
1539 RawExternalOneByteString* raw_string = 1539 RawExternalOneByteString* raw_string =
1540 reinterpret_cast<RawExternalOneByteString*>(raw_obj)->ptr(); 1540 reinterpret_cast<RawExternalOneByteString*>(raw_addr);
1541 ExternalStringData<uint8_t>* data = raw_string->external_data_; 1541 *peer = raw_string->peer();
1542 *peer = data->peer();
1543 return Api::Success(Isolate::Current()); 1542 return Api::Success(Isolate::Current());
1544 } 1543 }
1545 case kExternalTwoByteStringCid: { 1544 case kExternalTwoByteStringCid: {
1546 RawExternalTwoByteString* raw_string = 1545 RawExternalTwoByteString* raw_string =
1547 reinterpret_cast<RawExternalTwoByteString*>(raw_obj)->ptr(); 1546 reinterpret_cast<RawExternalTwoByteString*>(raw_addr);
1548 ExternalStringData<uint16_t>* data = raw_string->external_data_; 1547 *peer = raw_string->peer();
1549 *peer = data->peer();
1550 return Api::Success(Isolate::Current()); 1548 return Api::Success(Isolate::Current());
1551 } 1549 }
1552 case kExternalFourByteStringCid: { 1550 case kExternalFourByteStringCid: {
1553 RawExternalFourByteString* raw_string = 1551 RawExternalFourByteString* raw_string =
1554 reinterpret_cast<RawExternalFourByteString*>(raw_obj)->ptr(); 1552 reinterpret_cast<RawExternalFourByteString*>(raw_addr);
1555 ExternalStringData<uint32_t>* data = raw_string->external_data_; 1553 *peer = raw_string->peer();
1556 *peer = data->peer();
1557 return Api::Success(Isolate::Current()); 1554 return Api::Success(Isolate::Current());
1558 } 1555 }
1559 } 1556 }
1560 } 1557 }
1561 1558
1562 // It's not an external string, return appropriate error. 1559 // It's not an external string, return appropriate error.
1563 // Note: this is invoked outside of the NoGCScope'd block above, since 1560 // Note: this is invoked outside of the NoGCScope'd block above, since
1564 // error messages allocate new handles. 1561 // error messages allocate new handles.
1565 if (!RawObject::IsStringClassId(class_id)) { 1562 if (!RawObject::IsStringClassId(class_id)) {
1566 RETURN_TYPE_ERROR(Isolate::Current(), object, String); 1563 RETURN_TYPE_ERROR(Isolate::Current(), object, String);
(...skipping 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after
4179 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4176 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4180 Dart::set_perf_events_writer(function); 4177 Dart::set_perf_events_writer(function);
4181 } 4178 }
4182 4179
4183 4180
4184 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4181 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4185 Dart::set_flow_graph_writer(function); 4182 Dart::set_flow_graph_writer(function);
4186 } 4183 }
4187 4184
4188 } // namespace dart 4185 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/raw_object.h » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698