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

Side by Side Diff: runtime/vm/object.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
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | 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 "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 10479 matching lines...) Expand 10 before | Expand all | Expand 10 after
10490 weak_ref->set_raw(referent); 10490 weak_ref->set_raw(referent);
10491 weak_ref->set_peer(peer); 10491 weak_ref->set_peer(peer);
10492 weak_ref->set_callback(callback); 10492 weak_ref->set_callback(callback);
10493 } 10493 }
10494 10494
10495 10495
10496 RawString* String::MakeExternal(void* array, 10496 RawString* String::MakeExternal(void* array,
10497 intptr_t length, 10497 intptr_t length,
10498 void* peer, 10498 void* peer,
10499 Dart_PeerFinalizer cback) const { 10499 Dart_PeerFinalizer cback) const {
10500 NoGCScope no_gc;
10500 ASSERT(array != NULL); 10501 ASSERT(array != NULL);
10501 intptr_t str_length = this->Length(); 10502 intptr_t str_length = this->Length();
10502 ASSERT(length >= (str_length * this->CharSize())); 10503 ASSERT(length >= (str_length * this->CharSize()));
10503 intptr_t class_id = raw()->GetClassId(); 10504 intptr_t class_id = raw()->GetClassId();
10504 intptr_t used_size = 0; 10505 intptr_t used_size = 0;
10505 intptr_t original_size = 0; 10506 intptr_t original_size = 0;
10506 uword tags = 0; 10507 uword tags = raw_ptr()->tags_;
10507 NoGCScope no_gc;
10508 10508
10509 ASSERT(!IsCanonical());
10509 if (class_id == kOneByteStringCid) { 10510 if (class_id == kOneByteStringCid) {
10510 used_size = ExternalOneByteString::InstanceSize(); 10511 used_size = ExternalOneByteString::InstanceSize();
10511 original_size = OneByteString::InstanceSize(str_length); 10512 original_size = OneByteString::InstanceSize(str_length);
10512 ASSERT(original_size >= used_size); 10513 ASSERT(original_size >= used_size);
10513 10514
10514 // Copy the data into the external array. 10515 // Copy the data into the external array.
10515 if (str_length > 0) { 10516 if (str_length > 0) {
10516 memmove(array, OneByteString::CharAddr(*this, 0), str_length); 10517 memmove(array, OneByteString::CharAddr(*this, 0), str_length);
10517 } 10518 }
10518 10519
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
12172 } 12173 }
12173 return result.raw(); 12174 return result.raw();
12174 } 12175 }
12175 12176
12176 12177
12177 const char* WeakProperty::ToCString() const { 12178 const char* WeakProperty::ToCString() const {
12178 return "_WeakProperty"; 12179 return "_WeakProperty";
12179 } 12180 }
12180 12181
12181 } // namespace dart 12182 } // namespace dart
OLDNEW
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698