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

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

Issue 11411204: When externalizing a string ensure that the basic tag bits are preserved. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/object.cc » ('j') | runtime/vm/object.cc » ('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 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 const String& str_obj = Api::UnwrapStringHandle(isolate, str); 1742 const String& str_obj = Api::UnwrapStringHandle(isolate, str);
1743 if (str_obj.IsExternal()) { 1743 if (str_obj.IsExternal()) {
1744 return str; // String is already an external string. 1744 return str; // String is already an external string.
1745 } 1745 }
1746 if (str_obj.IsNull()) { 1746 if (str_obj.IsNull()) {
1747 RETURN_TYPE_ERROR(isolate, str, String); 1747 RETURN_TYPE_ERROR(isolate, str, String);
1748 } 1748 }
1749 if (array == NULL) { 1749 if (array == NULL) {
1750 RETURN_NULL_ERROR(array); 1750 RETURN_NULL_ERROR(array);
1751 } 1751 }
1752 Heap* vm_isolate_heap = Dart::vm_isolate()->heap();
1753 if (vm_isolate_heap->Contains(reinterpret_cast<uword>(str_obj.raw()))) {
cshapiro 2012/11/29 21:03:12 Is this the most efficient check? Can we use the
siva 2012/11/29 22:37:39 My initial thought was strings in the isolate can
1754 return Api::NewError("Dart_MakeExternalString "
1755 "cannot externalize a read only string.");
cshapiro 2012/11/29 21:03:12 s/read only/read-only/
siva 2012/11/29 22:37:39 Done.
1756 }
1752 intptr_t str_size = (str_obj.Length() * str_obj.CharSize()); 1757 intptr_t str_size = (str_obj.Length() * str_obj.CharSize());
1753 if ((length < str_size) || (length > String::kMaxElements)) { 1758 if ((length < str_size) || (length > String::kMaxElements)) {
1754 return Api::NewError("Dart_MakeExternalString " 1759 return Api::NewError("Dart_MakeExternalString "
1755 "expects argument length to be in the range" 1760 "expects argument length to be in the range"
1756 "[%"Pd"..%"Pd"].", 1761 "[%"Pd"..%"Pd"].",
1757 str_size, String::kMaxElements); 1762 str_size, String::kMaxElements);
1758 } 1763 }
1759 return Api::NewHandle(isolate, 1764 return Api::NewHandle(isolate,
1760 str_obj.MakeExternal(array, length, peer, cback)); 1765 str_obj.MakeExternal(array, length, peer, cback));
1761 } 1766 }
(...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after
4451 } 4456 }
4452 { 4457 {
4453 NoGCScope no_gc; 4458 NoGCScope no_gc;
4454 RawObject* raw_obj = obj.raw(); 4459 RawObject* raw_obj = obj.raw();
4455 isolate->heap()->SetPeer(raw_obj, peer); 4460 isolate->heap()->SetPeer(raw_obj, peer);
4456 } 4461 }
4457 return Api::Success(isolate); 4462 return Api::Success(isolate);
4458 } 4463 }
4459 4464
4460 } // namespace dart 4465 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698