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

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

Issue 569783003: Revert "Remove V8_HOST_CAN_READ_UNALIGNED and its uses." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
27 int32_t answer = data_[position_]; 30 int32_t answer = data_[position_];
28 answer |= data_[position_ + 1] << 8; 31 answer |= data_[position_ + 1] << 8;
29 answer |= data_[position_ + 2] << 16; 32 answer |= data_[position_ + 2] << 16;
30 answer |= data_[position_ + 3] << 24; 33 answer |= data_[position_ + 3] << 24;
34 #endif
31 return answer; 35 return answer;
32 } 36 }
33 37
34 38
35 void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) { 39 void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
36 MemCopy(to, data_ + position_, number_of_bytes); 40 MemCopy(to, data_ + position_, number_of_bytes);
37 position_ += number_of_bytes; 41 position_ += number_of_bytes;
38 } 42 }
39 43
40 44
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 92 }
89 93
90 94
91 void DebugSnapshotSink::Put(byte b, const char* description) { 95 void DebugSnapshotSink::Put(byte b, const char* description) {
92 PrintF("%24s: %x\n", description, b); 96 PrintF("%24s: %x\n", description, b);
93 sink_->Put(b, description); 97 sink_->Put(b, description);
94 } 98 }
95 99
96 } // namespace v8::internal 100 } // namespace v8::internal
97 } // namespace v8 101 } // 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