Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 82 |
| 83 // Cache Context pointer into CTX while executing Dart code. | 83 // Cache Context pointer into CTX while executing Dart code. |
| 84 __ movl(CTX, ECX); | 84 __ movl(CTX, ECX); |
| 85 | 85 |
| 86 __ LeaveFrame(); | 86 __ LeaveFrame(); |
| 87 __ ret(); | 87 __ ret(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 // Print the stop message. | 91 // Print the stop message. |
| 92 static void PrintStopMessage(const char* message) { | 92 DEFINE_LEAF_RUNTIME_ENTRY(void, PrintStopMessage, const char* message) { |
| 93 OS::Print("Stop message: %s\n", message); | 93 OS::Print("Stop message: %s\n", message); |
| 94 } | 94 } |
| 95 END_LEAF_RUNTIME_ENTRY | |
| 95 | 96 |
| 96 | 97 |
| 97 // Input parameters: | 98 // Input parameters: |
| 98 // ESP : points to return address. | 99 // ESP : points to return address. |
| 99 // EAX : stop message (const char*). | 100 // EAX : stop message (const char*). |
| 100 // Must preserve all registers, except EAX. | 101 // Must preserve all registers, except EAX. |
| 101 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { | 102 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { |
| 102 // Preserve caller-saved registers. | 103 __ enter(Immediate(0)); |
| 103 __ pushl(ECX); | 104 __ PreserveCallerSavedRegisters(); |
| 104 __ pushl(EDX); | |
| 105 | 105 |
| 106 // Create a stub frame as we are pushing some objects on the stack before | 106 // Call the runtime leaf function. |
| 107 // calling into the runtime. | 107 __ ReserveAlignedFrameSpace(kWordSize); |
|
siva
2012/07/09 22:51:07
1 * kWordSize to be uniform with similar code belo
Ivan Posva
2012/07/09 22:59:35
Done.
| |
| 108 AssemblerMacros::EnterStubFrame(assembler); | 108 __ movl(Address(ESP, 0), EAX); |
| 109 __ CallRuntime(kPrintStopMessageRuntimeEntry); | |
| 109 | 110 |
| 110 // Reserve space for the native argument and align frame before entering | 111 __ RestoreCallerSavedRegisters(); |
| 111 // the C++ world. | 112 __ leave(); |
| 112 __ AddImmediate(ESP, Immediate(-sizeof(kWordSize))); | |
| 113 if (OS::ActivationFrameAlignment() > 0) { | |
| 114 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | |
| 115 } | |
| 116 | |
| 117 // Pass argument and call native function. | |
| 118 __ movl(Address(ESP, 0), EAX); | |
| 119 __ movl(EAX, Immediate(reinterpret_cast<uword>(&PrintStopMessage))); | |
| 120 __ call(EAX); | |
| 121 __ popl(EAX); | |
| 122 | |
| 123 __ LeaveFrame(); | |
| 124 | |
| 125 // Restore caller-saved registers. | |
| 126 __ popl(EDX); | |
| 127 __ popl(ECX); | |
| 128 | |
| 129 __ ret(); | 113 __ ret(); |
| 130 } | 114 } |
| 131 | 115 |
| 132 | 116 |
| 133 // Input parameters: | 117 // Input parameters: |
| 134 // ESP : points to return address. | 118 // ESP : points to return address. |
| 135 // ESP + 4 : address of return value. | 119 // ESP + 4 : address of return value. |
| 136 // EAX : address of first argument in argument array. | 120 // EAX : address of first argument in argument array. |
| 137 // EAX - 4*EDX + 4 : address of last argument in argument array. | 121 // EAX - 4*EDX + 4 : address of last argument in argument array. |
| 138 // ECX : address of the native function to call. | 122 // ECX : address of the native function to call. |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 __ pushl(EDX); | 1056 __ pushl(EDX); |
| 1073 __ CallRuntime(kAllocateContextRuntimeEntry); // Allocate context. | 1057 __ CallRuntime(kAllocateContextRuntimeEntry); // Allocate context. |
| 1074 __ popl(EAX); // Pop number of context variables argument. | 1058 __ popl(EAX); // Pop number of context variables argument. |
| 1075 __ popl(EAX); // Pop the new context object. | 1059 __ popl(EAX); // Pop the new context object. |
| 1076 // EAX: new object | 1060 // EAX: new object |
| 1077 // Restore the frame pointer. | 1061 // Restore the frame pointer. |
| 1078 __ LeaveFrame(); | 1062 __ LeaveFrame(); |
| 1079 __ ret(); | 1063 __ ret(); |
| 1080 } | 1064 } |
| 1081 | 1065 |
| 1066 DECLARE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, Isolate* isolate); | |
| 1082 | 1067 |
| 1083 // Helper stub to implement Assembler::StoreIntoObject. | 1068 // Helper stub to implement Assembler::StoreIntoObject. |
| 1084 // Input parameters: | 1069 // Input parameters: |
| 1085 // EAX: Address being stored | 1070 // EAX: Address being stored |
| 1086 void StubCode::GenerateUpdateStoreBufferStub(Assembler* assembler) { | 1071 void StubCode::GenerateUpdateStoreBufferStub(Assembler* assembler) { |
| 1087 // Save values being destroyed. | 1072 // Save values being destroyed. |
| 1088 __ pushl(CTX); | 1073 __ pushl(EDX); |
| 1089 __ pushl(EBX); | 1074 __ pushl(ECX); |
| 1090 | 1075 |
| 1091 // Load the isolate out of the context. | 1076 // Load the isolate out of the context. |
| 1077 // Spilled: EDX, ECX | |
| 1092 // EAX: Address being stored | 1078 // EAX: Address being stored |
| 1093 __ movl(CTX, FieldAddress(CTX, Context::isolate_offset())); | 1079 __ movl(EDX, FieldAddress(CTX, Context::isolate_offset())); |
| 1094 | 1080 |
| 1095 // Load top_ out of the StoreBufferBlock and add the address to the pointers_. | 1081 // Load top_ out of the StoreBufferBlock and add the address to the pointers_. |
| 1082 // Spilled: EDX, ECX | |
| 1096 // EAX: Address being stored | 1083 // EAX: Address being stored |
| 1097 // CTX: Isolate | 1084 // EDX: Isolate |
| 1098 intptr_t store_buffer_offset = Isolate::store_buffer_block_offset(); | 1085 intptr_t store_buffer_offset = Isolate::store_buffer_block_offset(); |
| 1099 __ movl(EBX, | 1086 __ movl(ECX, |
| 1100 Address(CTX, store_buffer_offset + StoreBufferBlock::top_offset())); | 1087 Address(EDX, store_buffer_offset + StoreBufferBlock::top_offset())); |
| 1101 __ movl(Address(CTX, | 1088 __ movl(Address(EDX, |
| 1102 EBX, TIMES_4, | 1089 ECX, TIMES_4, |
| 1103 store_buffer_offset + StoreBufferBlock::pointers_offset()), | 1090 store_buffer_offset + StoreBufferBlock::pointers_offset()), |
| 1104 EAX); | 1091 EAX); |
| 1105 | 1092 |
| 1106 // Increment top_ and check for overflow. | 1093 // Increment top_ and check for overflow. |
| 1107 // EBX: top_ | 1094 // Spilled: EDX, ECX |
| 1108 // CTX: Isolate | 1095 // ECX: top_ |
| 1096 // EDX: Isolate | |
| 1109 Label L; | 1097 Label L; |
| 1110 __ incl(EBX); | 1098 __ incl(ECX); |
| 1111 __ movl(Address(CTX, store_buffer_offset + StoreBufferBlock::top_offset()), | 1099 __ movl(Address(EDX, store_buffer_offset + StoreBufferBlock::top_offset()), |
| 1112 EBX); | 1100 ECX); |
| 1113 __ cmpl(EBX, Immediate(StoreBufferBlock::kSize)); | 1101 __ cmpl(ECX, Immediate(StoreBufferBlock::kSize)); |
| 1114 __ j(NOT_EQUAL, &L, Assembler::kNearJump); | 1102 // Restore values. |
| 1103 // Spilled: EDX, ECX | |
| 1104 __ popl(ECX); | |
| 1105 __ popl(EDX); | |
| 1106 __ j(EQUAL, &L, Assembler::kNearJump); | |
| 1107 __ ret(); | |
| 1115 | 1108 |
| 1116 // Handle overflow: Reset the top_ pointer. | 1109 // Handle overflow: Call the runtime leaf function. |
| 1117 // CTX: Isolate | |
| 1118 __ movl(Address(CTX, store_buffer_offset + StoreBufferBlock::top_offset()), | |
| 1119 Immediate(0)); | |
| 1120 | |
| 1121 __ Bind(&L); | 1110 __ Bind(&L); |
| 1122 // Restore values. | 1111 // Setup frame, push callee-saved registers. |
| 1123 __ popl(EBX); | 1112 __ enter(Immediate(0)); |
| 1124 __ popl(CTX); | 1113 __ PreserveCallerSavedRegisters(); |
| 1114 __ movl(EAX, FieldAddress(CTX, Context::isolate_offset())); | |
| 1115 __ ReserveAlignedFrameSpace(1 * kWordSize); | |
| 1116 __ movl(Address(ESP, 0), EAX); // Push the isolate as the only argument. | |
| 1117 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry); | |
| 1118 // Restore callee-saved registers, tear down frame. | |
| 1119 __ RestoreCallerSavedRegisters(); | |
| 1120 __ leave(); | |
| 1125 __ ret(); | 1121 __ ret(); |
| 1126 } | 1122 } |
| 1127 | 1123 |
| 1128 | 1124 |
| 1129 // Called for inline allocation of objects. | 1125 // Called for inline allocation of objects. |
| 1130 // Input parameters: | 1126 // Input parameters: |
| 1131 // ESP + 8 : type arguments object (only if class is parameterized). | 1127 // ESP + 8 : type arguments object (only if class is parameterized). |
| 1132 // ESP + 4 : type arguments of instantiator (only if class is parameterized). | 1128 // ESP + 4 : type arguments of instantiator (only if class is parameterized). |
| 1133 // ESP : points to return address. | 1129 // ESP : points to return address. |
| 1134 // Uses EAX, EBX, ECX, EDX, EDI as temporary registers. | 1130 // Uses EAX, EBX, ECX, EDX, EDI as temporary registers. |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1948 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object. | 1944 __ movl(EAX, Address(ESP, 4 * kWordSize)); // Load error object. |
| 1949 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. | 1945 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. |
| 1950 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. | 1946 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. |
| 1951 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. | 1947 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. |
| 1952 __ jmp(EBX); // Jump to the exception handler code. | 1948 __ jmp(EBX); // Jump to the exception handler code. |
| 1953 } | 1949 } |
| 1954 | 1950 |
| 1955 } // namespace dart | 1951 } // namespace dart |
| 1956 | 1952 |
| 1957 #endif // defined TARGET_ARCH_IA32 | 1953 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |