OLD | NEW |
1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #if defined(FLETCH_TARGET_ARM) | 5 #if defined(DARTINO_TARGET_ARM) |
6 | 6 |
7 #include "src/shared/bytecodes.h" | 7 #include "src/shared/bytecodes.h" |
8 #include "src/shared/names.h" | 8 #include "src/shared/names.h" |
9 #include "src/shared/selectors.h" | 9 #include "src/shared/selectors.h" |
10 | 10 |
11 #include "src/vm/assembler.h" | 11 #include "src/vm/assembler.h" |
12 #include "src/vm/generator.h" | 12 #include "src/vm/generator.h" |
13 #include "src/vm/interpreter.h" | 13 #include "src/vm/interpreter.h" |
14 #include "src/vm/intrinsics.h" | 14 #include "src/vm/intrinsics.h" |
15 #include "src/vm/object.h" | 15 #include "src/vm/object.h" |
16 #include "src/vm/process.h" | 16 #include "src/vm/process.h" |
17 #include "src/vm/program.h" | 17 #include "src/vm/program.h" |
18 | 18 |
19 #define __ assembler()-> | 19 #define __ assembler()-> |
20 | 20 |
21 namespace fletch { | 21 namespace dartino { |
22 | 22 |
23 class InterpreterGenerator { | 23 class InterpreterGenerator { |
24 public: | 24 public: |
25 explicit InterpreterGenerator(Assembler* assembler) : assembler_(assembler) {} | 25 explicit InterpreterGenerator(Assembler* assembler) : assembler_(assembler) {} |
26 | 26 |
27 void Generate(); | 27 void Generate(); |
28 | 28 |
29 virtual void GeneratePrologue() = 0; | 29 virtual void GeneratePrologue() = 0; |
30 virtual void GenerateEpilogue() = 0; | 30 virtual void GenerateEpilogue() = 0; |
31 | 31 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 Push(R2); | 424 Push(R2); |
425 __ add(R5, R0, Immediate(Function::kSize - HeapObject::kTag)); | 425 __ add(R5, R0, Immediate(Function::kSize - HeapObject::kTag)); |
426 CheckStackOverflow(0); | 426 CheckStackOverflow(0); |
427 Dispatch(0); | 427 Dispatch(0); |
428 } | 428 } |
429 | 429 |
430 void InterpreterGeneratorARM::GenerateBytecodePrologue(const char* name) { | 430 void InterpreterGeneratorARM::GenerateBytecodePrologue(const char* name) { |
431 __ SwitchToText(); | 431 __ SwitchToText(); |
432 __ AlignToPowerOfTwo(3); | 432 __ AlignToPowerOfTwo(3); |
433 __ nop(); | 433 __ nop(); |
434 #ifdef FLETCH_THUMB_ONLY | 434 #ifdef DARTINO_THUMB_ONLY |
435 // Thumb is has 16-bit nop's, not 32-bit. | 435 // Thumb is has 16-bit nop's, not 32-bit. |
436 __ nop(); | 436 __ nop(); |
437 #endif | 437 #endif |
438 __ Bind("Debug_", name); | 438 __ Bind("Debug_", name); |
439 __ bl("DebugAtBytecode"); | 439 __ bl("DebugAtBytecode"); |
440 __ AlignToPowerOfTwo(3); | 440 __ AlignToPowerOfTwo(3); |
441 __ Bind("", name); | 441 __ Bind("", name); |
442 } | 442 } |
443 | 443 |
444 void InterpreterGeneratorARM::GenerateDebugAtBytecode() { | 444 void InterpreterGeneratorARM::GenerateDebugAtBytecode() { |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 void InterpreterGeneratorARM::DoIntrinsicListLength() { | 1399 void InterpreterGeneratorARM::DoIntrinsicListLength() { |
1400 // Load the backing store (array) from the first instance field of the list. | 1400 // Load the backing store (array) from the first instance field of the list. |
1401 LoadLocal(R2, 0); // List. | 1401 LoadLocal(R2, 0); // List. |
1402 __ ldr(R2, Address(R2, Instance::kSize - HeapObject::kTag)); | 1402 __ ldr(R2, Address(R2, Instance::kSize - HeapObject::kTag)); |
1403 __ ldr(R0, Address(R2, Array::kLengthOffset - HeapObject::kTag)); | 1403 __ ldr(R0, Address(R2, Array::kLengthOffset - HeapObject::kTag)); |
1404 | 1404 |
1405 __ mov(PC, LR); | 1405 __ mov(PC, LR); |
1406 } | 1406 } |
1407 | 1407 |
1408 void InterpreterGeneratorARM::Push(Register reg) { | 1408 void InterpreterGeneratorARM::Push(Register reg) { |
1409 #ifdef FLETCH_THUMB_ONLY | 1409 #ifdef DARTINO_THUMB_ONLY |
1410 StoreLocal(reg, -1); | 1410 StoreLocal(reg, -1); |
1411 __ sub(R6, R6, Immediate(1 * kWordSize)); | 1411 __ sub(R6, R6, Immediate(1 * kWordSize)); |
1412 #else | 1412 #else |
1413 __ str(reg, Address(R6, -1 * kWordSize), WRITE_BACK); | 1413 __ str(reg, Address(R6, -1 * kWordSize), WRITE_BACK); |
1414 #endif | 1414 #endif |
1415 } | 1415 } |
1416 | 1416 |
1417 void InterpreterGeneratorARM::Pop(Register reg) { | 1417 void InterpreterGeneratorARM::Pop(Register reg) { |
1418 #ifdef FLETCH_THUMB_ONLY | 1418 #ifdef DARTINO_THUMB_ONLY |
1419 LoadLocal(reg, 0); | 1419 LoadLocal(reg, 0); |
1420 Drop(1); | 1420 Drop(1); |
1421 #else | 1421 #else |
1422 __ ldr(reg, R6, Immediate(kWordSize)); | 1422 __ ldr(reg, R6, Immediate(kWordSize)); |
1423 #endif | 1423 #endif |
1424 } | 1424 } |
1425 | 1425 |
1426 void InterpreterGeneratorARM::Return(bool is_return_null) { | 1426 void InterpreterGeneratorARM::Return(bool is_return_null) { |
1427 // Materialize the result in register R0. | 1427 // Materialize the result in register R0. |
1428 if (is_return_null) { | 1428 if (is_return_null) { |
(...skipping 21 matching lines...) Expand all Loading... |
1450 | 1450 |
1451 void InterpreterGeneratorARM::Drop(int n) { | 1451 void InterpreterGeneratorARM::Drop(int n) { |
1452 __ add(R6, R6, Immediate(n * kWordSize)); | 1452 __ add(R6, R6, Immediate(n * kWordSize)); |
1453 } | 1453 } |
1454 | 1454 |
1455 void InterpreterGeneratorARM::Drop(Register reg) { | 1455 void InterpreterGeneratorARM::Drop(Register reg) { |
1456 __ add(R6, R6, Operand(reg, TIMES_WORD_SIZE)); | 1456 __ add(R6, R6, Operand(reg, TIMES_WORD_SIZE)); |
1457 } | 1457 } |
1458 | 1458 |
1459 void InterpreterGeneratorARM::DropNAndSetTop(int dropping_slots, Register reg) { | 1459 void InterpreterGeneratorARM::DropNAndSetTop(int dropping_slots, Register reg) { |
1460 #ifdef FLETCH_THUMB_ONLY | 1460 #ifdef DARTINO_THUMB_ONLY |
1461 Drop(dropping_slots); | 1461 Drop(dropping_slots); |
1462 StoreLocal(reg, 0); | 1462 StoreLocal(reg, 0); |
1463 #else | 1463 #else |
1464 __ str(reg, Address(R6, dropping_slots * kWordSize), WRITE_BACK); | 1464 __ str(reg, Address(R6, dropping_slots * kWordSize), WRITE_BACK); |
1465 #endif | 1465 #endif |
1466 } | 1466 } |
1467 | 1467 |
1468 void InterpreterGeneratorARM::LoadFramePointer(Register reg) { | 1468 void InterpreterGeneratorARM::LoadFramePointer(Register reg) { |
1469 __ ldr(reg, Address(SP, spill_size_)); | 1469 __ ldr(reg, Address(SP, spill_size_)); |
1470 } | 1470 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 // Compute the address of the first and last instance field. | 1920 // Compute the address of the first and last instance field. |
1921 __ sub(R7, R0, Immediate(kWordSize + HeapObject::kTag)); | 1921 __ sub(R7, R0, Immediate(kWordSize + HeapObject::kTag)); |
1922 __ add(R7, R7, R2); | 1922 __ add(R7, R7, R2); |
1923 __ add(R9, R0, Immediate(Instance::kSize - HeapObject::kTag)); | 1923 __ add(R9, R0, Immediate(Instance::kSize - HeapObject::kTag)); |
1924 | 1924 |
1925 Label loop, done; | 1925 Label loop, done; |
1926 __ Bind(&loop); | 1926 __ Bind(&loop); |
1927 __ cmp(R9, R7); | 1927 __ cmp(R9, R7); |
1928 __ b(HI, &done); | 1928 __ b(HI, &done); |
1929 Pop(R1); | 1929 Pop(R1); |
1930 #ifdef FLETCH_THUMB_ONLY | 1930 #ifdef DARTINO_THUMB_ONLY |
1931 __ str(R1, Address(R7, 0)); | 1931 __ str(R1, Address(R7, 0)); |
1932 __ sub(R7, R7, Immediate(1 * kWordSize)); | 1932 __ sub(R7, R7, Immediate(1 * kWordSize)); |
1933 #else | 1933 #else |
1934 __ str(R1, R7, Immediate(-1 * kWordSize)); | 1934 __ str(R1, R7, Immediate(-1 * kWordSize)); |
1935 #endif | 1935 #endif |
1936 __ b(&loop); | 1936 __ b(&loop); |
1937 | 1937 |
1938 __ Bind(&done); | 1938 __ Bind(&done); |
1939 Push(R0); | 1939 Push(R0); |
1940 Dispatch(kAllocateLength); | 1940 Dispatch(kAllocateLength); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 Label done; | 1987 Label done; |
1988 __ b(HI, &done); | 1988 __ b(HI, &done); |
1989 __ mov(R0, Immediate(size)); | 1989 __ mov(R0, Immediate(size)); |
1990 __ b(&check_stack_overflow_); | 1990 __ b(&check_stack_overflow_); |
1991 __ Bind(&done); | 1991 __ Bind(&done); |
1992 } | 1992 } |
1993 } | 1993 } |
1994 | 1994 |
1995 void InterpreterGeneratorARM::Dispatch(int size) { | 1995 void InterpreterGeneratorARM::Dispatch(int size) { |
1996 // Load the next bytecode through R5 and dispatch to it. | 1996 // Load the next bytecode through R5 and dispatch to it. |
1997 #ifdef FLETCH_THUMB_ONLY | 1997 #ifdef DARTINO_THUMB_ONLY |
1998 __ ldrb(R7, Address(R5, size)); | 1998 __ ldrb(R7, Address(R5, size)); |
1999 if (size > 0) { | 1999 if (size > 0) { |
2000 __ add(R5, R5, Immediate(size)); | 2000 __ add(R5, R5, Immediate(size)); |
2001 } | 2001 } |
2002 #else | 2002 #else |
2003 __ ldrb(R7, Address(R5, size), WRITE_BACK); | 2003 __ ldrb(R7, Address(R5, size), WRITE_BACK); |
2004 #endif | 2004 #endif |
2005 __ ldr(R9, "Interpret_DispatchTable"); | 2005 __ ldr(R9, "Interpret_DispatchTable"); |
2006 __ ldr(PC, Address(R9, Operand(R7, TIMES_WORD_SIZE))); | 2006 __ ldr(PC, Address(R9, Operand(R7, TIMES_WORD_SIZE))); |
2007 __ GenerateConstantPool(); | 2007 __ GenerateConstantPool(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 StoreFramePointer(R5); | 2047 StoreFramePointer(R5); |
2048 | 2048 |
2049 // Set the bytecode pointer from the stack. | 2049 // Set the bytecode pointer from the stack. |
2050 __ ldr(R5, Address(R5, -kWordSize)); | 2050 __ ldr(R5, Address(R5, -kWordSize)); |
2051 | 2051 |
2052 // Pop and branch to resume address. | 2052 // Pop and branch to resume address. |
2053 Pop(LR); | 2053 Pop(LR); |
2054 __ mov(PC, LR); | 2054 __ mov(PC, LR); |
2055 } | 2055 } |
2056 | 2056 |
2057 } // namespace fletch | 2057 } // namespace dartino |
2058 | 2058 |
2059 #endif // defined(FLETCH_TARGET_ARM) | 2059 #endif // defined(DARTINO_TARGET_ARM) |
OLD | NEW |