OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
9 | 9 |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| 11 #include "vm/dart_entry.h" |
11 #include "vm/flow_graph_compiler.h" | 12 #include "vm/flow_graph_compiler.h" |
12 #include "vm/instructions.h" | 13 #include "vm/instructions.h" |
13 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/regexp_assembler.h" |
14 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
15 | 17 |
16 namespace dart { | 18 namespace dart { |
17 | 19 |
18 DECLARE_FLAG(bool, enable_type_checks); | 20 DECLARE_FLAG(bool, enable_type_checks); |
19 | 21 |
20 // When entering intrinsics code: | 22 // When entering intrinsics code: |
21 // RBX: IC Data | 23 // RBX: IC Data |
22 // R10: Arguments descriptor | 24 // R10: Arguments descriptor |
23 // TOS: Return address | 25 // TOS: Return address |
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 void Intrinsifier::OneByteString_equality(Assembler* assembler) { | 1909 void Intrinsifier::OneByteString_equality(Assembler* assembler) { |
1908 StringEquality(assembler, kOneByteStringCid); | 1910 StringEquality(assembler, kOneByteStringCid); |
1909 } | 1911 } |
1910 | 1912 |
1911 | 1913 |
1912 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { | 1914 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
1913 StringEquality(assembler, kTwoByteStringCid); | 1915 StringEquality(assembler, kTwoByteStringCid); |
1914 } | 1916 } |
1915 | 1917 |
1916 | 1918 |
| 1919 void Intrinsifier::JSRegExp_ExecuteMatch(Assembler* assembler) { |
| 1920 static const intptr_t kRegExpParamOffset = + 3 * kWordSize; |
| 1921 static const intptr_t kStringParamOffset = + 2 * kWordSize; |
| 1922 // const Smi& start_index is located at (+ 1 * kWordSize). |
| 1923 |
| 1924 // Register assignments are as follows: |
| 1925 // RAX: The appropriate specialized matcher function. |
| 1926 // RBX: The regexp object. |
| 1927 // RDI: Temp, Pointer to the function's code which we then tail-call. |
| 1928 |
| 1929 __ movq(RBX, Address(RSP, kRegExpParamOffset)); |
| 1930 __ movq(RDI, Address(RSP, kStringParamOffset)); |
| 1931 |
| 1932 // Load the specialized function pointer into RAX. Leverage the fact the |
| 1933 // string CIDs as well as stored function pointers are in sequence. |
| 1934 |
| 1935 __ LoadClassId(RDI, RDI); |
| 1936 __ SubImmediate(RDI, Immediate(kOneByteStringCid), PP); |
| 1937 __ movq(RAX, FieldAddress(RBX, RDI, TIMES_8, |
| 1938 JSRegExp::function_offset(kOneByteStringCid))); |
| 1939 |
| 1940 // Registers have been set up for the lazy compile stub at this point. |
| 1941 // It expects the function in RAX, the argument descriptor in R10, and |
| 1942 // IC-Data in RCX. Explicitly null out IC-Data to ensure its validity. |
| 1943 |
| 1944 static const intptr_t arg_count = RegExpMacroAssembler::kParamCount; |
| 1945 __ LoadObject(R10, Array::Handle(ArgumentsDescriptor::New(arg_count)), PP); |
| 1946 __ xorq(RCX, RCX); |
| 1947 |
| 1948 // Tail-call the function. |
| 1949 __ movq(RDI, FieldAddress(RAX, Function::instructions_offset())); |
| 1950 __ addq(RDI, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1951 __ jmp(RDI); |
| 1952 } |
| 1953 |
| 1954 |
1917 // On stack: user tag (+1), return-address (+0). | 1955 // On stack: user tag (+1), return-address (+0). |
1918 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { | 1956 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
1919 // RBX: Isolate. | 1957 // RBX: Isolate. |
1920 Isolate* isolate = Isolate::Current(); | 1958 Isolate* isolate = Isolate::Current(); |
1921 const Immediate& isolate_address = | 1959 const Immediate& isolate_address = |
1922 Immediate(reinterpret_cast<int64_t>(isolate)); | 1960 Immediate(reinterpret_cast<int64_t>(isolate)); |
1923 __ movq(RBX, isolate_address); | 1961 __ movq(RBX, isolate_address); |
1924 // RAX: Current user tag. | 1962 // RAX: Current user tag. |
1925 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); | 1963 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); |
1926 // R10: UserTag. | 1964 // R10: UserTag. |
(...skipping 30 matching lines...) Expand all Loading... |
1957 // Set return value to Isolate::current_tag_. | 1995 // Set return value to Isolate::current_tag_. |
1958 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); | 1996 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); |
1959 __ ret(); | 1997 __ ret(); |
1960 } | 1998 } |
1961 | 1999 |
1962 #undef __ | 2000 #undef __ |
1963 | 2001 |
1964 } // namespace dart | 2002 } // namespace dart |
1965 | 2003 |
1966 #endif // defined TARGET_ARCH_X64 | 2004 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |