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

Side by Side Diff: vm/raw_object_snapshot.cc

Issue 10446104: Use memmove instead of a loop to read bytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 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 | vm/snapshot.h » ('j') | 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/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/visitor.h" 9 #include "vm/visitor.h"
10 10
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, 1208 RawBigint* Bigint::ReadFrom(SnapshotReader* reader,
1209 intptr_t object_id, 1209 intptr_t object_id,
1210 intptr_t tags, 1210 intptr_t tags,
1211 Snapshot::Kind kind) { 1211 Snapshot::Kind kind) {
1212 ASSERT(reader != NULL); 1212 ASSERT(reader != NULL);
1213 1213
1214 // Read in the HexCString representation of the bigint. 1214 // Read in the HexCString representation of the bigint.
1215 intptr_t len = reader->ReadIntptrValue(); 1215 intptr_t len = reader->ReadIntptrValue();
1216 char* str = reinterpret_cast<char*>(ZoneAllocator(len + 1)); 1216 char* str = reinterpret_cast<char*>(ZoneAllocator(len + 1));
1217 str[len] = '\0'; 1217 str[len] = '\0';
1218 for (intptr_t i = 0; i < len; i++) { 1218 reader->ReadBytes(reinterpret_cast<uint8_t*>(str), len);
1219 str[i] = reader->Read<uint8_t>();
1220 }
1221 1219
1222 // Create a Bigint object from HexCString. 1220 // Create a Bigint object from HexCString.
1223 Bigint& obj = Bigint::ZoneHandle( 1221 Bigint& obj = Bigint::ZoneHandle(
1224 reader->isolate(), 1222 reader->isolate(),
1225 (kind == Snapshot::kFull) ? reader->NewBigint(str) : 1223 (kind == Snapshot::kFull) ? reader->NewBigint(str) :
1226 BigintOperations::FromHexCString(str)); 1224 BigintOperations::FromHexCString(str));
1227 1225
1228 // If it is a canonical constant make it one. 1226 // If it is a canonical constant make it one.
1229 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags)) { 1227 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags)) {
1230 obj ^= obj.Canonicalize(); 1228 obj ^= obj.Canonicalize();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 intptr_t hash = reader->ReadSmiValue(); 1377 intptr_t hash = reader->ReadSmiValue();
1380 OneByteString& str_obj = OneByteString::ZoneHandle(reader->isolate(), 1378 OneByteString& str_obj = OneByteString::ZoneHandle(reader->isolate(),
1381 OneByteString::null()); 1379 OneByteString::null());
1382 1380
1383 if (kind == Snapshot::kFull) { 1381 if (kind == Snapshot::kFull) {
1384 ASSERT(reader->isolate()->no_gc_scope_depth() != 0); 1382 ASSERT(reader->isolate()->no_gc_scope_depth() != 0);
1385 RawOneByteString* obj = reader->NewOneByteString(len); 1383 RawOneByteString* obj = reader->NewOneByteString(len);
1386 str_obj = obj; 1384 str_obj = obj;
1387 str_obj.set_tags(tags); 1385 str_obj.set_tags(tags);
1388 obj->ptr()->hash_ = Smi::New(hash); 1386 obj->ptr()->hash_ = Smi::New(hash);
1389 uint8_t* raw_ptr = (len > 0) ? str_obj.CharAddr(0) : NULL; 1387 if (len > 0) {
1390 for (intptr_t i = 0; i < len; i++) { 1388 uint8_t* raw_ptr = str_obj.CharAddr(0);
1391 ASSERT(str_obj.CharAddr(i) == raw_ptr); // Will trigger assertions. 1389 reader->ReadBytes(raw_ptr, len);
1392 *raw_ptr = reader->Read<uint8_t>();
1393 raw_ptr += 1;
1394 } 1390 }
1395 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); 1391 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash));
1396 } else { 1392 } else {
1397 ReadFromImpl<OneByteString, uint8_t>(reader, &str_obj, len, tags); 1393 ReadFromImpl<OneByteString, uint8_t>(reader, &str_obj, len, tags);
1398 } 1394 }
1399 reader->AddBackwardReference(object_id, &str_obj); 1395 reader->AddBackwardReference(object_id, &str_obj);
1400 return str_obj.raw(); 1396 return str_obj.raw();
1401 } 1397 }
1402 1398
1403 1399
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 2399 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
2404 writer->WriteObject(ptr()->pattern_); 2400 writer->WriteObject(ptr()->pattern_);
2405 writer->WriteIntptrValue(ptr()->type_); 2401 writer->WriteIntptrValue(ptr()->type_);
2406 writer->WriteIntptrValue(ptr()->flags_); 2402 writer->WriteIntptrValue(ptr()->flags_);
2407 2403
2408 // Do not write out the data part which is native. 2404 // Do not write out the data part which is native.
2409 } 2405 }
2410 2406
2411 2407
2412 } // namespace dart 2408 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698