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

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

Issue 1316943002: Move (uppercase) JS builtins from js builtins object to native context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove Isolate::js_builtins_object Created 5 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
« no previous file with comments | « src/x87/macro-assembler-x87.cc ('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 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 "test/unittests/compiler/interpreter-assembler-unittest.h" 5 #include "test/unittests/compiler/interpreter-assembler-unittest.h"
6 6
7 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/unique.h" 9 #include "src/unique.h"
10 #include "test/unittests/compiler/compiler-test-utils.h" 10 #include "test/unittests/compiler/compiler-test-utils.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); 262 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize)));
263 EXPECT_THAT(m.SmiUntag(value), 263 EXPECT_THAT(m.SmiUntag(value),
264 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); 264 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize)));
265 } 265 }
266 } 266 }
267 267
268 268
269 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { 269 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) {
270 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 270 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
271 InterpreterAssemblerForTest m(this, bytecode); 271 InterpreterAssemblerForTest m(this, bytecode);
272 Node* load_context = m.LoadContextSlot(22); 272 Node* load_from_current_context = m.LoadContextSlot(22);
273 EXPECT_THAT(load_context, 273 Matcher<Node*> load_from_current_context_matcher = m.IsLoad(
274 m.IsLoad(kMachAnyTagged, 274 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter),
275 IsParameter(Linkage::kInterpreterContextParameter), 275 IsIntPtrConstant(Context::SlotOffset(22)));
276 IsIntPtrConstant(Context::SlotOffset(22)))); 276 EXPECT_THAT(load_from_current_context, load_from_current_context_matcher);
277
278 // Let's imagine that the loaded context slot is another context.
279 Node* load_from_any_context =
280 m.LoadContextSlot(load_from_current_context, 23);
281 EXPECT_THAT(load_from_any_context,
282 m.IsLoad(kMachAnyTagged, load_from_current_context_matcher,
283 IsIntPtrConstant(Context::SlotOffset(23))));
277 } 284 }
278 } 285 }
279 286
280 287
281 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { 288 TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) {
282 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 289 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
283 InterpreterAssemblerForTest m(this, bytecode); 290 InterpreterAssemblerForTest m(this, bytecode);
284 Node* object = m.IntPtrConstant(0xdeadbeef); 291 Node* object = m.IntPtrConstant(0xdeadbeef);
285 int offset = 16; 292 int offset = 16;
286 Node* load_field = m.LoadObjectField(object, offset); 293 Node* load_field = m.LoadObjectField(object, offset);
287 EXPECT_THAT(load_field, 294 EXPECT_THAT(load_field,
288 m.IsLoad(kMachAnyTagged, object, 295 m.IsLoad(kMachAnyTagged, object,
289 IsIntPtrConstant(offset - kHeapObjectTag))); 296 IsIntPtrConstant(offset - kHeapObjectTag)));
290 } 297 }
291 } 298 }
292 299
293 300
294 TARGET_TEST_F(InterpreterAssemblerTest, CallJSBuiltin) { 301 TARGET_TEST_F(InterpreterAssemblerTest, CallJSBuiltin) {
295 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { 302 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
296 InterpreterAssemblerForTest m(this, bytecode); 303 InterpreterAssemblerForTest m(this, bytecode);
297 Node* receiver = m.IntPtrConstant(1234); 304 Node* receiver = m.IntPtrConstant(1234);
298 Node* call_js_builtin_0 = m.CallJSBuiltin(Builtins::SUB, receiver); 305 Node* call_js_builtin_0 =
306 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver);
299 307
300 Matcher<Node*> load_globals_matcher = m.IsLoad( 308 Matcher<Node*> load_globals_matcher = m.IsLoad(
301 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), 309 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter),
302 IsIntPtrConstant(Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); 310 IsIntPtrConstant(Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
303 Matcher<Node*> load_builtins_matcher = m.IsLoad( 311 Matcher<Node*> load_native_context_matcher = m.IsLoad(
304 kMachAnyTagged, load_globals_matcher, 312 kMachAnyTagged, load_globals_matcher,
305 IsIntPtrConstant(GlobalObject::kBuiltinsOffset - kHeapObjectTag)); 313 IsIntPtrConstant(GlobalObject::kNativeContextOffset - kHeapObjectTag));
306 Matcher<Node*> function_matcher = 314 Matcher<Node*> function_matcher = m.IsLoad(
307 m.IsLoad(kMachAnyTagged, load_builtins_matcher, 315 kMachAnyTagged, load_native_context_matcher,
308 IsIntPtrConstant( 316 IsIntPtrConstant(Context::SlotOffset(Context::SUB_BUILTIN_INDEX)));
309 JSBuiltinsObject::OffsetOfFunctionWithId(Builtins::SUB) -
310 kHeapObjectTag));
311 Matcher<Node*> context_matcher = 317 Matcher<Node*> context_matcher =
312 m.IsLoad(kMachAnyTagged, function_matcher, 318 m.IsLoad(kMachAnyTagged, function_matcher,
313 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag)); 319 IsIntPtrConstant(JSFunction::kContextOffset - kHeapObjectTag));
314 EXPECT_THAT(call_js_builtin_0, 320 EXPECT_THAT(call_js_builtin_0,
315 IsCall(_, function_matcher, receiver, context_matcher, 321 IsCall(_, function_matcher, receiver, context_matcher,
316 m.graph()->start(), m.graph()->start())); 322 m.graph()->start(), m.graph()->start()));
317 323
318 Node* arg1 = m.Int32Constant(0xabcd); 324 Node* arg1 = m.Int32Constant(0xabcd);
319 Node* call_js_builtin_1 = m.CallJSBuiltin(Builtins::SUB, receiver, arg1); 325 Node* call_js_builtin_1 =
326 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver, arg1);
320 EXPECT_THAT(call_js_builtin_1, 327 EXPECT_THAT(call_js_builtin_1,
321 IsCall(_, function_matcher, receiver, arg1, context_matcher, 328 IsCall(_, function_matcher, receiver, arg1, context_matcher,
322 m.graph()->start(), m.graph()->start())); 329 m.graph()->start(), m.graph()->start()));
323 } 330 }
324 } 331 }
325 332
326 } // namespace compiler 333 } // namespace compiler
327 } // namespace internal 334 } // namespace internal
328 } // namespace v8 335 } // namespace v8
OLDNEW
« no previous file with comments | « src/x87/macro-assembler-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698