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 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1060 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry, 1); | 1060 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry, 1); |
| 1061 __ LeaveCallRuntimeFrame(); | 1061 __ LeaveCallRuntimeFrame(); |
| 1062 __ ret(); | 1062 __ ret(); |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 | 1065 |
| 1066 // Called for inline allocation of objects. | 1066 // Called for inline allocation of objects. |
| 1067 // Input parameters: | 1067 // Input parameters: |
| 1068 // RSP + 8 : type arguments object (only if class is parameterized). | 1068 // RSP + 8 : type arguments object (only if class is parameterized). |
| 1069 // RSP : points to return address. | 1069 // RSP : points to return address. |
| 1070 uword StubCode::GenerateAllocationStubForClass(Assembler* assembler, | 1070 void StubCode::GenerateAllocationStubForClass( |
| 1071 const Class& cls) { | 1071 Assembler* assembler, const Class& cls, |
| 1072 uword* entry_patch_offset, uword* patch_code_pc_offset) { | |
| 1073 // Must set-up a PP before being able to patch. | |
| 1074 Register new_pp = R13; | |
| 1075 Register new_pc = R12; | |
| 1076 | |
| 1077 Label next; | |
| 1078 __ nop(4); // Need a fixed size sequence on frame entry. | |
| 1079 __ call(&next); | |
| 1080 __ Bind(&next); | |
| 1081 | |
| 1082 const intptr_t object_pool_pc_dist = | |
| 1083 Instructions::HeaderSize() - Instructions::object_pool_offset() + | |
| 1084 __ CodeSize(); | |
| 1085 const intptr_t offset = | |
| 1086 Assembler::EntryPointToPcMarkerOffset() - __ CodeSize(); | |
| 1087 __ popq(new_pc); | |
| 1088 if (offset != 0) { | |
| 1089 __ addq(new_pc, Immediate(offset)); | |
| 1090 } | |
| 1091 | |
| 1092 // Load pool pointer. | |
| 1093 __ movq(new_pp, Address(new_pc, -object_pool_pc_dist - offset)); | |
| 1094 *entry_patch_offset = assembler->CodeSize(); | |
|
zra
2014/09/16 20:55:58
Since this is a delicate bit of code, I'd recommen
srdjan
2014/09/16 21:54:50
Good suggestion! Done.
| |
| 1095 | |
| 1072 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize; | 1096 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize; |
| 1073 // The generated code is different if the class is parameterized. | 1097 // The generated code is different if the class is parameterized. |
| 1074 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; | 1098 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; |
| 1075 ASSERT(!is_cls_parameterized || | 1099 ASSERT(!is_cls_parameterized || |
| 1076 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); | 1100 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); |
| 1077 // kInlineInstanceSize is a constant used as a threshold for determining | 1101 // kInlineInstanceSize is a constant used as a threshold for determining |
| 1078 // when the object initialization should be done as a loop or as | 1102 // when the object initialization should be done as a loop or as |
| 1079 // straight line code. | 1103 // straight line code. |
| 1080 const int kInlineInstanceSize = 12; // In words. | 1104 const int kInlineInstanceSize = 12; // In words. |
| 1081 const intptr_t instance_size = cls.instance_size(); | 1105 const intptr_t instance_size = cls.instance_size(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1173 __ pushq(R12); // Push null type arguments. | 1197 __ pushq(R12); // Push null type arguments. |
| 1174 } | 1198 } |
| 1175 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object. | 1199 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object. |
| 1176 __ popq(RAX); // Pop argument (type arguments of object). | 1200 __ popq(RAX); // Pop argument (type arguments of object). |
| 1177 __ popq(RAX); // Pop argument (class of object). | 1201 __ popq(RAX); // Pop argument (class of object). |
| 1178 __ popq(RAX); // Pop result (newly allocated object). | 1202 __ popq(RAX); // Pop result (newly allocated object). |
| 1179 // RAX: new object | 1203 // RAX: new object |
| 1180 // Restore the frame pointer. | 1204 // Restore the frame pointer. |
| 1181 __ LeaveStubFrame(); | 1205 __ LeaveStubFrame(); |
| 1182 __ ret(); | 1206 __ ret(); |
| 1183 uword patch_code_pc_offset = assembler->CodeSize(); | 1207 *patch_code_pc_offset = assembler->CodeSize(); |
| 1184 StubCode* stub_code = Isolate::Current()->stub_code(); | 1208 StubCode* stub_code = Isolate::Current()->stub_code(); |
| 1185 __ JmpPatchable(&stub_code->FixAllocationStubTargetLabel(), R13); | 1209 __ JmpPatchable(&stub_code->FixAllocationStubTargetLabel(), new_pp); |
| 1186 return patch_code_pc_offset; | |
| 1187 } | 1210 } |
| 1188 | 1211 |
| 1189 | 1212 |
| 1190 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function | 1213 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function |
| 1191 // from the entry code of a dart function after an error in passed argument | 1214 // from the entry code of a dart function after an error in passed argument |
| 1192 // name or number is detected. | 1215 // name or number is detected. |
| 1193 // Input parameters: | 1216 // Input parameters: |
| 1194 // RSP : points to return address. | 1217 // RSP : points to return address. |
| 1195 // RSP + 8 : address of last argument. | 1218 // RSP + 8 : address of last argument. |
| 1196 // R10 : arguments descriptor array. | 1219 // R10 : arguments descriptor array. |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2022 | 2045 |
| 2023 __ movq(left, Address(RSP, 2 * kWordSize)); | 2046 __ movq(left, Address(RSP, 2 * kWordSize)); |
| 2024 __ movq(right, Address(RSP, 1 * kWordSize)); | 2047 __ movq(right, Address(RSP, 1 * kWordSize)); |
| 2025 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 2048 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
| 2026 __ ret(); | 2049 __ ret(); |
| 2027 } | 2050 } |
| 2028 | 2051 |
| 2029 } // namespace dart | 2052 } // namespace dart |
| 2030 | 2053 |
| 2031 #endif // defined TARGET_ARCH_X64 | 2054 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |