Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: src/mips/regexp-macro-assembler-mips.cc

Issue 24321002: MIPS: replace RegExpCEntryStub with DirectCEntryStub. (Closed) Base URL: git@github.com:paul99/v8m-rb.git@master
Patch Set: comment added. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips/regexp-macro-assembler-mips.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 1056
1057 1057
1058 bool RegExpMacroAssemblerMIPS::CanReadUnaligned() { 1058 bool RegExpMacroAssemblerMIPS::CanReadUnaligned() {
1059 return false; 1059 return false;
1060 } 1060 }
1061 1061
1062 1062
1063 // Private methods: 1063 // Private methods:
1064 1064
1065 void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) { 1065 void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) {
1066 static const int num_arguments = 3; 1066 int stack_alignment = OS::ActivationFrameAlignment();
1067 __ PrepareCallCFunction(num_arguments, scratch); 1067
1068 // Align the stack pointer and save the original sp value on the stack.
1069 __ mov(scratch, sp);
1070 __ Subu(sp, sp, Operand(kPointerSize));
1071 ASSERT(IsPowerOf2(stack_alignment));
1072 __ And(sp, sp, Operand(-stack_alignment));
1073 __ sw(scratch, MemOperand(sp));
1074
1068 __ mov(a2, frame_pointer()); 1075 __ mov(a2, frame_pointer());
1069 // Code* of self. 1076 // Code* of self.
1070 __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE); 1077 __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE);
1071 // a0 becomes return address pointer. 1078
1079 // We need to make room for the return address on the stack.
1080 ASSERT(IsAligned(stack_alignment, kPointerSize));
1081 __ Subu(sp, sp, Operand(stack_alignment));
1082
1083 // Stack pointer now points to cell where return address is to be written.
1084 // Arguments are in registers, meaning we teat the return address as
1085 // argument 5. Since DirectCEntryStub will handleallocating space for the C
1086 // argument slots, we don't need to care about that here. This is how the
1087 // stack will look (sp meaning the value of sp at this moment):
1088 // [sp + 3] - empty slot if needed for alignment.
1089 // [sp + 2] - saved sp.
1090 // [sp + 1] - second word reserved for return value.
1091 // [sp + 0] - first word reserved for return value.
1092
1093 // a0 will point to the return address, placed by DirectCEntry.
1094 __ mov(a0, sp);
1095
1072 ExternalReference stack_guard_check = 1096 ExternalReference stack_guard_check =
1073 ExternalReference::re_check_stack_guard_state(masm_->isolate()); 1097 ExternalReference::re_check_stack_guard_state(masm_->isolate());
1074 CallCFunctionUsingStub(stack_guard_check, num_arguments); 1098 __ li(t9, Operand(stack_guard_check));
1099 DirectCEntryStub stub;
1100 stub.GenerateCall(masm_, t9);
1101
1102 // DirectCEntryStub allocated space for the C argument slots so we have to
1103 // drop them with the return address from the stack with loading saved sp.
1104 // At this point stack must look:
1105 // [sp + 7] - empty slot if needed for alignment.
1106 // [sp + 6] - saved sp.
1107 // [sp + 5] - second word reserved for return value.
1108 // [sp + 4] - first word reserved for return value.
1109 // [sp + 3] - C argument slot.
1110 // [sp + 2] - C argument slot.
1111 // [sp + 1] - C argument slot.
1112 // [sp + 0] - C argument slot.
1113 __ lw(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize));
1114
1115 __ li(code_pointer(), Operand(masm_->CodeObject()));
1075 } 1116 }
1076 1117
1077 1118
1078 // Helper function for reading a value out of a stack frame. 1119 // Helper function for reading a value out of a stack frame.
1079 template <typename T> 1120 template <typename T>
1080 static T& frame_entry(Address re_frame, int frame_offset) { 1121 static T& frame_entry(Address re_frame, int frame_offset) {
1081 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset)); 1122 return reinterpret_cast<T&>(Memory::int32_at(re_frame + frame_offset));
1082 } 1123 }
1083 1124
1084 1125
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 void RegExpMacroAssemblerMIPS::CheckStackLimit() { 1310 void RegExpMacroAssemblerMIPS::CheckStackLimit() {
1270 ExternalReference stack_limit = 1311 ExternalReference stack_limit =
1271 ExternalReference::address_of_regexp_stack_limit(masm_->isolate()); 1312 ExternalReference::address_of_regexp_stack_limit(masm_->isolate());
1272 1313
1273 __ li(a0, Operand(stack_limit)); 1314 __ li(a0, Operand(stack_limit));
1274 __ lw(a0, MemOperand(a0)); 1315 __ lw(a0, MemOperand(a0));
1275 SafeCall(&stack_overflow_label_, ls, backtrack_stackpointer(), Operand(a0)); 1316 SafeCall(&stack_overflow_label_, ls, backtrack_stackpointer(), Operand(a0));
1276 } 1317 }
1277 1318
1278 1319
1279 void RegExpMacroAssemblerMIPS::CallCFunctionUsingStub(
1280 ExternalReference function,
1281 int num_arguments) {
1282 // Must pass all arguments in registers. The stub pushes on the stack.
1283 ASSERT(num_arguments <= 4);
1284 __ li(code_pointer(), Operand(function));
1285 RegExpCEntryStub stub;
1286 __ CallStub(&stub);
1287 if (OS::ActivationFrameAlignment() != 0) {
1288 __ lw(sp, MemOperand(sp, 16));
1289 }
1290 __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE);
1291 }
1292
1293
1294 void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset, 1320 void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset,
1295 int characters) { 1321 int characters) {
1296 Register offset = current_input_offset(); 1322 Register offset = current_input_offset();
1297 if (cp_offset != 0) { 1323 if (cp_offset != 0) {
1298 // t7 is not being used to store the capture start index at this point. 1324 // t7 is not being used to store the capture start index at this point.
1299 __ Addu(t7, current_input_offset(), Operand(cp_offset * char_size())); 1325 __ Addu(t7, current_input_offset(), Operand(cp_offset * char_size()));
1300 offset = t7; 1326 offset = t7;
1301 } 1327 }
1302 // We assume that we cannot do unaligned loads on MIPS, so this function 1328 // We assume that we cannot do unaligned loads on MIPS, so this function
1303 // must only be used to load a single character at a time. 1329 // must only be used to load a single character at a time.
1304 ASSERT(characters == 1); 1330 ASSERT(characters == 1);
1305 __ Addu(t5, end_of_input_address(), Operand(offset)); 1331 __ Addu(t5, end_of_input_address(), Operand(offset));
1306 if (mode_ == ASCII) { 1332 if (mode_ == ASCII) {
1307 __ lbu(current_character(), MemOperand(t5, 0)); 1333 __ lbu(current_character(), MemOperand(t5, 0));
1308 } else { 1334 } else {
1309 ASSERT(mode_ == UC16); 1335 ASSERT(mode_ == UC16);
1310 __ lhu(current_character(), MemOperand(t5, 0)); 1336 __ lhu(current_character(), MemOperand(t5, 0));
1311 } 1337 }
1312 } 1338 }
1313 1339
1314 1340
1315 void RegExpCEntryStub::Generate(MacroAssembler* masm_) {
1316 int stack_alignment = OS::ActivationFrameAlignment();
1317 if (stack_alignment < kPointerSize) stack_alignment = kPointerSize;
1318 // Stack is already aligned for call, so decrement by alignment
1319 // to make room for storing the return address.
1320 __ Subu(sp, sp, Operand(stack_alignment + kCArgsSlotsSize));
1321 const int return_address_offset = kCArgsSlotsSize;
1322 __ Addu(a0, sp, return_address_offset);
1323 __ sw(ra, MemOperand(a0, 0));
1324 __ mov(t9, t1);
1325 __ Call(t9);
1326 __ lw(ra, MemOperand(sp, return_address_offset));
1327 __ Addu(sp, sp, Operand(stack_alignment + kCArgsSlotsSize));
1328 __ Jump(ra);
1329 }
1330
1331
1332 #undef __ 1341 #undef __
1333 1342
1334 #endif // V8_INTERPRETED_REGEXP 1343 #endif // V8_INTERPRETED_REGEXP
1335 1344
1336 }} // namespace v8::internal 1345 }} // namespace v8::internal
1337 1346
1338 #endif // V8_TARGET_ARCH_MIPS 1347 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/regexp-macro-assembler-mips.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698