Chromium Code Reviews| 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" | |
| 17 #include "vm/flow_graph_compiler.h" | 18 #include "vm/flow_graph_compiler.h" |
| 18 #include "vm/object.h" | 19 #include "vm/object.h" |
| 19 #include "vm/object_store.h" | 20 #include "vm/object_store.h" |
| 20 #include "vm/os.h" | 21 #include "vm/os.h" |
| 21 #include "vm/stub_code.h" | 22 #include "vm/regexp_assembler.h" |
| 22 #include "vm/symbols.h" | 23 #include "vm/symbols.h" |
| 23 | 24 |
| 24 namespace dart { | 25 namespace dart { |
| 25 | 26 |
| 26 DECLARE_FLAG(bool, enable_type_checks); | 27 DECLARE_FLAG(bool, enable_type_checks); |
| 27 | 28 |
| 28 | 29 |
| 29 #define __ assembler-> | 30 #define __ assembler-> |
| 30 | 31 |
| 31 | 32 |
| (...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2056 void Intrinsifier::OneByteString_equality(Assembler* assembler) { | 2057 void Intrinsifier::OneByteString_equality(Assembler* assembler) { |
| 2057 StringEquality(assembler, kOneByteStringCid); | 2058 StringEquality(assembler, kOneByteStringCid); |
| 2058 } | 2059 } |
| 2059 | 2060 |
| 2060 | 2061 |
| 2061 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { | 2062 void Intrinsifier::TwoByteString_equality(Assembler* assembler) { |
| 2062 StringEquality(assembler, kTwoByteStringCid); | 2063 StringEquality(assembler, kTwoByteStringCid); |
| 2063 } | 2064 } |
| 2064 | 2065 |
| 2065 | 2066 |
| 2067 void Intrinsifier::JSRegExp_ExecuteMatch(Assembler* assembler) { | |
| 2068 static const intptr_t kRegExpParamOffset = + 3 * kWordSize; | |
| 2069 static const intptr_t kStringParamOffset = + 2 * kWordSize; | |
| 2070 // const Smi& start_index is located at (+ 1 * kWordSize). | |
| 2071 | |
| 2072 // Register assignments are as follows: | |
| 2073 // EAX: The appropriate specialized matcher function. | |
| 2074 // EBX: The regexp object. | |
| 2075 // EDI: Temp, Pointer to the function's code which we then tail-call. | |
| 2076 | |
| 2077 __ movl(EBX, Address(ESP, kRegExpParamOffset)); | |
| 2078 __ movl(EDI, Address(ESP, kStringParamOffset)); | |
| 2079 | |
| 2080 | |
| 2081 // Load the specialized function pointer into EAX. Leverage the fact the | |
| 2082 // string CIDs as well as stored function pointers are in sequence. | |
| 2083 | |
| 2084 __ LoadClassId(EDI, EDI); | |
| 2085 __ SubImmediate(EDI, Immediate(kOneByteStringCid)); | |
| 2086 __ movl(EAX, FieldAddress(EBX, EDI, TIMES_4, | |
| 2087 JSRegExp::function_offset(kOneByteStringCid))); | |
| 2088 | |
| 2089 // Registers have been set up for the lazy compile stub at this point. | |
| 2090 // It expects the function in EAX, the argument descriptor in EDX, and | |
| 2091 // IC-Data in ECX. Explicitly null out IC-Data to ensure its validity. | |
| 2092 | |
| 2093 static const intptr_t arg_count = RegExpMacroAssembler::kParamCount; | |
| 2094 __ LoadObject(EDX, Array::Handle(ArgumentsDescriptor::New(arg_count))); | |
| 2095 __ movl(ECX, Immediate(reinterpret_cast<intptr_t>(Object::null()))); | |
|
Florian Schneider
2014/10/07 12:49:36
Alternatively, just store smi 0:
__ xorl(ECX, ECX
jgruber1
2014/10/07 15:00:25
Done.
| |
| 2096 | |
| 2097 // Tail-call the function. | |
| 2098 __ movl(EDI, FieldAddress(EAX, Function::instructions_offset())); | |
| 2099 __ addl(EDI, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | |
| 2100 __ jmp(EDI); | |
| 2101 } | |
| 2102 | |
| 2103 | |
| 2066 // On stack: user tag (+1), return-address (+0). | 2104 // On stack: user tag (+1), return-address (+0). |
| 2067 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { | 2105 void Intrinsifier::UserTag_makeCurrent(Assembler* assembler) { |
| 2068 Isolate* isolate = Isolate::Current(); | 2106 Isolate* isolate = Isolate::Current(); |
| 2069 const Address current_tag_addr = | 2107 const Address current_tag_addr = |
| 2070 Address::Absolute(reinterpret_cast<uword>(isolate) + | 2108 Address::Absolute(reinterpret_cast<uword>(isolate) + |
| 2071 Isolate::current_tag_offset()); | 2109 Isolate::current_tag_offset()); |
| 2072 const Address user_tag_addr = | 2110 const Address user_tag_addr = |
| 2073 Address::Absolute(reinterpret_cast<uword>(isolate) + | 2111 Address::Absolute(reinterpret_cast<uword>(isolate) + |
| 2074 Isolate::user_tag_offset()); | 2112 Isolate::user_tag_offset()); |
| 2075 // EAX: Current user tag. | 2113 // EAX: Current user tag. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2104 Isolate::current_tag_offset()); | 2142 Isolate::current_tag_offset()); |
| 2105 // Set return value to Isolate::current_tag_. | 2143 // Set return value to Isolate::current_tag_. |
| 2106 __ movl(EAX, current_tag_addr); | 2144 __ movl(EAX, current_tag_addr); |
| 2107 __ ret(); | 2145 __ ret(); |
| 2108 } | 2146 } |
| 2109 | 2147 |
| 2110 #undef __ | 2148 #undef __ |
| 2111 } // namespace dart | 2149 } // namespace dart |
| 2112 | 2150 |
| 2113 #endif // defined TARGET_ARCH_IA32 | 2151 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |