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

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

Issue 209003009: Fix memory-issue String::fromCharCodes, where a GC could invalidate an address. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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/vm/object.h ('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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 16275 matching lines...) Expand 10 before | Expand all | Expand 10 after
16286 if (other_len > 0) { 16286 if (other_len > 0) {
16287 NoGCScope no_gc; 16287 NoGCScope no_gc;
16288 memmove(OneByteString::CharAddr(result, 0), 16288 memmove(OneByteString::CharAddr(result, 0),
16289 OneByteString::CharAddr(other_one_byte_string, other_start_index), 16289 OneByteString::CharAddr(other_one_byte_string, other_start_index),
16290 other_len); 16290 other_len);
16291 } 16291 }
16292 return OneByteString::raw(result); 16292 return OneByteString::raw(result);
16293 } 16293 }
16294 16294
16295 16295
16296 RawOneByteString* OneByteString::New(const TypedData& other_typed_data,
16297 intptr_t other_start_index,
16298 intptr_t other_len,
16299 Heap::Space space) {
16300 const String& result = String::Handle(OneByteString::New(other_len, space));
16301 ASSERT(other_typed_data.ElementSizeInBytes() == 1);
16302 if (other_len > 0) {
16303 NoGCScope no_gc;
16304 memmove(OneByteString::CharAddr(result, 0),
16305 other_typed_data.DataAddr(other_start_index),
16306 other_len);
16307 }
16308 return OneByteString::raw(result);
16309 }
16310
16311
16312 RawOneByteString* OneByteString::New(const ExternalTypedData& other_typed_data,
16313 intptr_t other_start_index,
16314 intptr_t other_len,
16315 Heap::Space space) {
16316 const String& result = String::Handle(OneByteString::New(other_len, space));
16317 ASSERT(other_typed_data.ElementSizeInBytes() == 1);
16318 if (other_len > 0) {
16319 NoGCScope no_gc;
16320 memmove(OneByteString::CharAddr(result, 0),
16321 other_typed_data.DataAddr(other_start_index),
16322 other_len);
16323 }
16324 return OneByteString::raw(result);
16325 }
16326
16327
16296 RawOneByteString* OneByteString::Concat(const String& str1, 16328 RawOneByteString* OneByteString::Concat(const String& str1,
16297 const String& str2, 16329 const String& str2,
16298 Heap::Space space) { 16330 Heap::Space space) {
16299 intptr_t len1 = str1.Length(); 16331 intptr_t len1 = str1.Length();
16300 intptr_t len2 = str2.Length(); 16332 intptr_t len2 = str2.Length();
16301 intptr_t len = len1 + len2; 16333 intptr_t len = len1 + len2;
16302 const String& result = String::Handle(OneByteString::New(len, space)); 16334 const String& result = String::Handle(OneByteString::New(len, space));
16303 String::Copy(result, 0, str1, 0, len1); 16335 String::Copy(result, 0, str1, 0, len1);
16304 String::Copy(result, len1, str2, 0, len2); 16336 String::Copy(result, len1, str2, 0, len2);
16305 return OneByteString::raw(result); 16337 return OneByteString::raw(result);
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after
17961 return "_MirrorReference"; 17993 return "_MirrorReference";
17962 } 17994 }
17963 17995
17964 17996
17965 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17997 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17966 Instance::PrintToJSONStream(stream, ref); 17998 Instance::PrintToJSONStream(stream, ref);
17967 } 17999 }
17968 18000
17969 18001
17970 } // namespace dart 18002 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698