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

Side by Side Diff: test/unittests/interpreter/bytecodes-unittest.cc

Issue 1881423002: Adjust bytecode operand values for big endian. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Swap BE and LE data Created 4 years, 8 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
« no previous file with comments | « no previous file | test/unittests/unittests.status » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include <vector> 5 #include <vector>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/interpreter/bytecodes.h" 9 #include "src/interpreter/bytecodes.h"
10 #include "test/unittests/test-utils.h" 10 #include "test/unittests/test-utils.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 TEST(Bytecodes, DecodeBytecodeAndOperands) { 180 TEST(Bytecodes, DecodeBytecodeAndOperands) {
181 struct BytecodesAndResult { 181 struct BytecodesAndResult {
182 const uint8_t bytecode[32]; 182 const uint8_t bytecode[32];
183 const size_t length; 183 const size_t length;
184 int parameter_count; 184 int parameter_count;
185 const char* output; 185 const char* output;
186 }; 186 };
187 187
188 #define B(Name) static_cast<uint8_t>(Bytecode::k##Name) 188 #define B(Name) static_cast<uint8_t>(Bytecode::k##Name)
189 const BytecodesAndResult cases[] = { 189 const BytecodesAndResult cases[] = {
190 {{B(LdaSmi), 0x01}, 2, 0, " LdaSmi [1]"}, 190 #if V8_TARGET_LITTLE_ENDIAN
191 {{B(Wide), B(LdaSmi), 0xe8, 0x03}, 4, 0, " LdaSmi.Wide [1000]"}, 191 {{B(LdaSmi), 0x01}, 2, 0, " LdaSmi [1]"},
192 {{B(ExtraWide), B(LdaSmi), 0xa0, 0x86, 0x01, 0x00}, 192 {{B(Wide), B(LdaSmi), 0xe8, 0x03}, 4, 0, " LdaSmi.Wide [1000]"},
193 6, 193 {{B(ExtraWide), B(LdaSmi), 0xa0, 0x86, 0x01, 0x00},
194 0, 194 6,
195 "LdaSmi.ExtraWide [100000]"}, 195 0,
196 {{B(LdaSmi), 0xff}, 2, 0, " LdaSmi [-1]"}, 196 "LdaSmi.ExtraWide [100000]"},
197 {{B(Wide), B(LdaSmi), 0x18, 0xfc}, 4, 0, " LdaSmi.Wide [-1000]"}, 197 {{B(LdaSmi), 0xff}, 2, 0, " LdaSmi [-1]"},
198 {{B(ExtraWide), B(LdaSmi), 0x60, 0x79, 0xfe, 0xff}, 198 {{B(Wide), B(LdaSmi), 0x18, 0xfc}, 4, 0, " LdaSmi.Wide [-1000]"},
199 6, 199 {{B(ExtraWide), B(LdaSmi), 0x60, 0x79, 0xfe, 0xff},
200 0, 200 6,
201 "LdaSmi.ExtraWide [-100000]"}, 201 0,
202 {{B(Star), 0xfb}, 2, 0, " Star r5"}, 202 "LdaSmi.ExtraWide [-100000]"},
203 {{B(Wide), B(Star), 0x78, 0xff}, 4, 0, " Star.Wide r136"}, 203 {{B(Star), 0xfb}, 2, 0, " Star r5"},
204 {{B(Wide), B(Call), 0x7a, 0xff, 0x79, 0xff, 0x02, 0x00, 0xb1, 0x00}, 204 {{B(Wide), B(Star), 0x78, 0xff}, 4, 0, " Star.Wide r136"},
205 10, 205 {{B(Wide), B(Call), 0x7a, 0xff, 0x79, 0xff, 0x02, 0x00, 0xb1, 0x00},
206 0, 206 10,
207 "Call.Wide r134, r135, #2, [177]"}, 207 0,
208 {{B(Ldar), 208 "Call.Wide r134, r135, #2, [177]"},
209 static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())}, 209 {{B(Ldar),
210 2, 210 static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())},
211 3, 211 2,
212 " Ldar a1"}, 212 3,
213 {{B(Wide), B(CreateObjectLiteral), 0x01, 0x02, 0x03, 0x04, 0xa5}, 213 " Ldar a1"},
214 7, 214 {{B(Wide), B(CreateObjectLiteral), 0x01, 0x02, 0x03, 0x04, 0xa5},
215 0, 215 7,
216 "CreateObjectLiteral.Wide [513], [1027], #165"}, 216 0,
217 {{B(ExtraWide), B(JumpIfNull), 0x15, 0xcd, 0x5b, 0x07}, 217 "CreateObjectLiteral.Wide [513], [1027], #165"},
218 6, 218 {{B(ExtraWide), B(JumpIfNull), 0x15, 0xcd, 0x5b, 0x07},
219 0, 219 6,
220 "JumpIfNull.ExtraWide [123456789]"}, 220 0,
221 "JumpIfNull.ExtraWide [123456789]"},
222 #elif V8_TARGET_BIG_ENDIAN
223 {{B(LdaSmi), 0x01}, 2, 0, " LdaSmi [1]"},
224 {{B(Wide), B(LdaSmi), 0x03, 0xe8}, 4, 0, " LdaSmi.Wide [1000]"},
225 {{B(ExtraWide), B(LdaSmi), 0x00, 0x01, 0x86, 0xa0},
226 6,
227 0,
228 "LdaSmi.ExtraWide [100000]"},
229 {{B(LdaSmi), 0xff}, 2, 0, " LdaSmi [-1]"},
230 {{B(Wide), B(LdaSmi), 0xfc, 0x18}, 4, 0, " LdaSmi.Wide [-1000]"},
231 {{B(ExtraWide), B(LdaSmi), 0xff, 0xfe, 0x79, 0x60},
232 6,
233 0,
234 "LdaSmi.ExtraWide [-100000]"},
235 {{B(Star), 0xfb}, 2, 0, " Star r5"},
236 {{B(Wide), B(Star), 0xff, 0x78}, 4, 0, " Star.Wide r136"},
237 {{B(Wide), B(Call), 0xff, 0x7a, 0xff, 0x79, 0x00, 0x02, 0x00, 0xb1},
238 10,
239 0,
240 "Call.Wide r134, r135, #2, [177]"},
241 {{B(Ldar),
242 static_cast<uint8_t>(Register::FromParameterIndex(2, 3).ToOperand())},
243 2,
244 3,
245 " Ldar a1"},
246 {{B(Wide), B(CreateObjectLiteral), 0x02, 0x01, 0x04, 0x03, 0xa5},
247 7,
248 0,
249 "CreateObjectLiteral.Wide [513], [1027], #165"},
250 {{B(ExtraWide), B(JumpIfNull), 0x07, 0x5b, 0xcd, 0x15},
251 6,
252 0,
253 "JumpIfNull.ExtraWide [123456789]"},
254 #else
255 #error "Unknown Architecture"
256 #endif
221 }; 257 };
222 #undef B 258 #undef B
223 259
224 for (size_t i = 0; i < arraysize(cases); ++i) { 260 for (size_t i = 0; i < arraysize(cases); ++i) {
225 // Generate reference string by prepending formatted bytes. 261 // Generate reference string by prepending formatted bytes.
226 std::stringstream expected_ss; 262 std::stringstream expected_ss;
227 std::ios default_format(nullptr); 263 std::ios default_format(nullptr);
228 default_format.copyfmt(expected_ss); 264 default_format.copyfmt(expected_ss);
229 // Match format of Bytecodes::Decode() for byte representations. 265 // Match format of Bytecodes::Decode() for byte representations.
230 expected_ss.fill('0'); 266 expected_ss.fill('0');
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone)); 347 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kNone));
312 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead)); 348 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kRead));
313 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite)); 349 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kWrite));
314 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite)); 350 names.insert(Bytecodes::AccumulatorUseToString(AccumulatorUse::kReadWrite));
315 CHECK_EQ(names.size(), 4); 351 CHECK_EQ(names.size(), 4);
316 } 352 }
317 353
318 } // namespace interpreter 354 } // namespace interpreter
319 } // namespace internal 355 } // namespace internal
320 } // namespace v8 356 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/unittests/unittests.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698