Revision f230a1cf deps/v8/src/mips/regexp-macro-assembler-mips.cc

View differences:

deps/v8/src/mips/regexp-macro-assembler-mips.cc
1063 1063
// Private methods:
1064 1064

  
1065 1065
void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) {
1066
  static const int num_arguments = 3;
1067
  __ PrepareCallCFunction(num_arguments, scratch);
1066
  int stack_alignment = OS::ActivationFrameAlignment();
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 1075
  __ mov(a2, frame_pointer());
1069 1076
  // Code* of self.
1070 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 1096
  ExternalReference stack_guard_check =
1073 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

  
......
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 1320
void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset,
1295 1321
                                                             int characters) {
1296 1322
  Register offset = current_input_offset();
......
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 1341
#undef __
1333 1342

  
1334 1343
#endif  // V8_INTERPRETED_REGEXP

Also available in: Unified diff