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

Side by Side Diff: src/snapshot-source-sink.cc

Issue 571903002: Reland "Remove V8_HOST_CAN_READ_UNALIGNED and its uses." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 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 | « src/runtime.cc ('k') | src/utils.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include "src/snapshot-source-sink.h" 6 #include "src/snapshot-source-sink.h"
7 7
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/handles-inl.h" 9 #include "src/handles-inl.h"
10 #include "src/serialize.h" // for SerializerDeserializer::nop() in AtEOF() 10 #include "src/serialize.h" // for SerializerDeserializer::nop() in AtEOF()
11 11
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 16
17 SnapshotByteSource::SnapshotByteSource(const byte* array, int length) 17 SnapshotByteSource::SnapshotByteSource(const byte* array, int length)
18 : data_(array), length_(length), position_(0) { 18 : data_(array), length_(length), position_(0) {
19 } 19 }
20 20
21 21
22 SnapshotByteSource::~SnapshotByteSource() { } 22 SnapshotByteSource::~SnapshotByteSource() { }
23 23
24 24
25 int32_t SnapshotByteSource::GetUnalignedInt() { 25 int32_t SnapshotByteSource::GetUnalignedInt() {
26 DCHECK(position_ < length_); // Require at least one byte left. 26 DCHECK(position_ < length_); // Require at least one byte left.
27 #if defined(V8_HOST_CAN_READ_UNALIGNED) && __BYTE_ORDER == __LITTLE_ENDIAN
28 int32_t answer = *reinterpret_cast<const int32_t*>(data_ + position_);
29 #else
30 int32_t answer = data_[position_]; 27 int32_t answer = data_[position_];
31 answer |= data_[position_ + 1] << 8; 28 answer |= data_[position_ + 1] << 8;
32 answer |= data_[position_ + 2] << 16; 29 answer |= data_[position_ + 2] << 16;
33 answer |= data_[position_ + 3] << 24; 30 answer |= data_[position_ + 3] << 24;
34 #endif
35 return answer; 31 return answer;
36 } 32 }
37 33
38 34
39 void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) { 35 void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
40 MemCopy(to, data_ + position_, number_of_bytes); 36 MemCopy(to, data_ + position_, number_of_bytes);
41 position_ += number_of_bytes; 37 position_ += number_of_bytes;
42 } 38 }
43 39
44 40
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 88 }
93 89
94 90
95 void DebugSnapshotSink::Put(byte b, const char* description) { 91 void DebugSnapshotSink::Put(byte b, const char* description) {
96 PrintF("%24s: %x\n", description, b); 92 PrintF("%24s: %x\n", description, b);
97 sink_->Put(b, description); 93 sink_->Put(b, description);
98 } 94 }
99 95
100 } // namespace v8::internal 96 } // namespace v8::internal
101 } // namespace v8 97 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698