| 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 // The intrinsic code below is executed before a method has built its frame. | 5 // The intrinsic code below is executed before a method has built its frame. |
| 6 // The return address is on the stack and the arguments below it. | 6 // The return address is on the stack and the arguments below it. |
| 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. | 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. |
| 8 // Each intrinsification method returns true if the corresponding | 8 // Each intrinsification method returns true if the corresponding |
| 9 // Dart method was intrinsified. | 9 // Dart method was intrinsified. |
| 10 | 10 |
| 11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 11 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 12 #if defined(TARGET_ARCH_IA32) | 12 #if defined(TARGET_ARCH_IA32) |
| 13 | 13 |
| 14 #include "vm/intrinsifier.h" | 14 #include "vm/intrinsifier.h" |
| 15 | 15 |
| 16 #include "vm/assembler.h" | 16 #include "vm/assembler.h" |
| 17 #include "vm/dart_entry.h" | |
| 18 #include "vm/flow_graph_compiler.h" | 17 #include "vm/flow_graph_compiler.h" |
| 19 #include "vm/object.h" | 18 #include "vm/object.h" |
| 20 #include "vm/object_store.h" | 19 #include "vm/object_store.h" |
| 21 #include "vm/os.h" | 20 #include "vm/os.h" |
| 22 #include "vm/regexp_assembler.h" | 21 #include "vm/stub_code.h" |
| 23 #include "vm/symbols.h" | 22 #include "vm/symbols.h" |
| 24 | 23 |
| 25 namespace dart { | 24 namespace dart { |
| 26 | 25 |
| 27 DECLARE_FLAG(bool, enable_type_checks); | 26 DECLARE_FLAG(bool, enable_type_checks); |
| 28 | 27 |
| 29 | 28 |
| 30 #define __ assembler-> | 29 #define __ assembler-> |
| 31 | 30 |
| 32 | 31 |
| (...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 void Intrinsifier::OneByteString_equality(Assembler* assembler) { | 2042 void Intrinsifier::OneByteString_equality(Assembler* assembler) { |
| 2044 StringEquality(assembler, kOneByteStringCid); | 2043 StringEquality(assembler, kOneByteStringCid); |
| 2045 } | 2044 } |
| 2046 | 2045 |
| 2047 | 2046 |
| 2048 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { | 2047 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
| 2049 StringEquality(assembler, kTwoByteStringCid); | 2048 StringEquality(assembler, kTwoByteStringCid); |
| 2050 } | 2049 } |
| 2051 | 2050 |
| 2052 | 2051 |
| 2053 void Intrinsifier::JSRegExp_ExecuteMatch(Assembler* assembler) { | |
| 2054 if (FLAG_use_jscre) { | |
| 2055 return; | |
| 2056 } | |
| 2057 static const intptr_t kRegExpParamOffset = 3 * kWordSize; | |
| 2058 static const intptr_t kStringParamOffset = 2 * kWordSize; | |
| 2059 // start_index smi is located at offset 1. | |
| 2060 | |
| 2061 // Incoming registers: | |
| 2062 // EAX: Function. (Will be loaded with the specialized matcher function.) | |
| 2063 // ECX: IC-Data. (Will be preserved.) | |
| 2064 // EDX: Arguments descriptor. (Will be preserved.) | |
| 2065 | |
| 2066 // Load the specialized function pointer into EAX. Leverage the fact the | |
| 2067 // string CIDs as well as stored function pointers are in sequence. | |
| 2068 __ movl(EBX, Address(ESP, kRegExpParamOffset)); | |
| 2069 __ movl(EDI, Address(ESP, kStringParamOffset)); | |
| 2070 __ LoadClassId(EDI, EDI); | |
| 2071 __ SubImmediate(EDI, Immediate(kOneByteStringCid)); | |
| 2072 __ movl(EAX, FieldAddress(EBX, EDI, TIMES_4, | |
| 2073 JSRegExp::function_offset(kOneByteStringCid))); | |
| 2074 | |
| 2075 // Registers are now set up for the lazy compile stub. It expects the function | |
| 2076 // in EAX, the argument descriptor in EDX, and IC-Data in ECX. | |
| 2077 static const intptr_t arg_count = RegExpMacroAssembler::kParamCount; | |
| 2078 __ LoadObject(EDX, Array::Handle(ArgumentsDescriptor::New(arg_count))); | |
| 2079 | |
| 2080 // Tail-call the function. | |
| 2081 __ movl(EDI, FieldAddress(EAX, Function::instructions_offset())); | |
| 2082 __ addl(EDI, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | |
| 2083 __ jmp(EDI); | |
| 2084 } | |
| 2085 | |
| 2086 | |
| 2087 // On stack: user tag (+1), return-address (+0). | 2052 // On stack: user tag (+1), return-address (+0). |
| 2088 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { | 2053 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
| 2089 Isolate* isolate = Isolate::Current(); | 2054 Isolate* isolate = Isolate::Current(); |
| 2090 const Address current_tag_addr = | 2055 const Address current_tag_addr = |
| 2091 Address::Absolute(reinterpret_cast<uword>(isolate) + | 2056 Address::Absolute(reinterpret_cast<uword>(isolate) + |
| 2092 Isolate::current_tag_offset()); | 2057 Isolate::current_tag_offset()); |
| 2093 const Address user_tag_addr = | 2058 const Address user_tag_addr = |
| 2094 Address::Absolute(reinterpret_cast<uword>(isolate) + | 2059 Address::Absolute(reinterpret_cast<uword>(isolate) + |
| 2095 Isolate::user_tag_offset()); | 2060 Isolate::user_tag_offset()); |
| 2096 // EAX: Current user tag. | 2061 // EAX: Current user tag. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2125 Isolate::current_tag_offset()); | 2090 Isolate::current_tag_offset()); |
| 2126 // Set return value to Isolate::current_tag_. | 2091 // Set return value to Isolate::current_tag_. |
| 2127 __ movl(EAX, current_tag_addr); | 2092 __ movl(EAX, current_tag_addr); |
| 2128 __ ret(); | 2093 __ ret(); |
| 2129 } | 2094 } |
| 2130 | 2095 |
| 2131 #undef __ | 2096 #undef __ |
| 2132 } // namespace dart | 2097 } // namespace dart |
| 2133 | 2098 |
| 2134 #endif // defined TARGET_ARCH_IA32 | 2099 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |