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

Side by Side Diff: src/macro-assembler-ia32.cc

Issue 4035: Refactored the code for entering and leaving exit frames (calls... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 int type = StackFrame::INTERNAL; 318 int type = StackFrame::INTERNAL;
319 319
320 push(ebp); 320 push(ebp);
321 mov(ebp, Operand(esp)); 321 mov(ebp, Operand(esp));
322 push(esi); 322 push(esi);
323 push(Immediate(Smi::FromInt(type))); 323 push(Immediate(Smi::FromInt(type)));
324 push(Immediate(0)); // Push an empty code cache slot. 324 push(Immediate(0)); // Push an empty code cache slot.
325 } 325 }
326 326
327 327
328 void MacroAssembler::ExitInternalFrame() { 328 void MacroAssembler::LeaveInternalFrame() {
329 if (FLAG_debug_code) { 329 if (FLAG_debug_code) {
330 StackFrame::Type type = StackFrame::INTERNAL; 330 StackFrame::Type type = StackFrame::INTERNAL;
331 cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), 331 cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset),
332 Immediate(Smi::FromInt(type))); 332 Immediate(Smi::FromInt(type)));
333 Check(equal, "stack frame types must match"); 333 Check(equal, "stack frame types must match");
334 } 334 }
335 leave(); 335 leave();
336 } 336 }
337 337
338 338
339 void MacroAssembler::EnterExitFrame(StackFrame::Type type) {
340 ASSERT(type == StackFrame::EXIT || type == StackFrame::EXIT_DEBUG);
341
342 // Setup the frame structure on the stack.
343 ASSERT(ExitFrameConstants::kPPDisplacement == +2 * kPointerSize);
344 ASSERT(ExitFrameConstants::kCallerPCOffset == +1 * kPointerSize);
345 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize);
346 push(ebp);
347 mov(ebp, Operand(esp));
348
349 // Reserve room for entry stack pointer and push the debug marker.
350 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize);
351 push(Immediate(0)); // saved entry sp, patched before call
352 push(Immediate(type == StackFrame::EXIT_DEBUG ? 1 : 0));
353
354 // Save the frame pointer and the context in top.
355 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address);
356 ExternalReference context_address(Top::k_context_address);
357 mov(Operand::StaticVariable(c_entry_fp_address), ebp);
358 mov(Operand::StaticVariable(context_address), esi);
359
360 // Setup argc and argv in callee-saved registers.
361 int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize;
362 mov(edi, Operand(eax));
363 lea(esi, Operand(ebp, eax, times_4, offset));
364 }
365
366
367 void MacroAssembler::LeaveExitFrame() {
368 // Get the return address from the stack and restore the frame pointer.
369 mov(ecx, Operand(ebp, 1 * kPointerSize));
370 mov(ebp, Operand(ebp, 0 * kPointerSize));
371
372 // Pop the arguments and the receiver from the caller stack.
373 lea(esp, Operand(esi, 1 * kPointerSize));
374
375 // Restore current context from top and clear it in debug mode.
376 ExternalReference context_address(Top::k_context_address);
377 mov(esi, Operand::StaticVariable(context_address));
378 if (kDebug) {
379 mov(Operand::StaticVariable(context_address), Immediate(0));
380 }
381
382 // Push the return address to get ready to return.
383 push(ecx);
384
385 // Clear the top frame.
386 ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address);
387 mov(Operand::StaticVariable(c_entry_fp_address), Immediate(0));
388 }
389
390
339 void MacroAssembler::PushTryHandler(CodeLocation try_location, 391 void MacroAssembler::PushTryHandler(CodeLocation try_location,
340 HandlerType type) { 392 HandlerType type) {
341 ASSERT(StackHandlerConstants::kSize == 6 * kPointerSize); // adjust this code 393 ASSERT(StackHandlerConstants::kSize == 6 * kPointerSize); // adjust this code
342 // The pc (return address) is already on TOS. 394 // The pc (return address) is already on TOS.
343 if (try_location == IN_JAVASCRIPT) { 395 if (try_location == IN_JAVASCRIPT) {
344 if (type == TRY_CATCH_HANDLER) { 396 if (type == TRY_CATCH_HANDLER) {
345 push(Immediate(StackHandler::TRY_CATCH)); 397 push(Immediate(StackHandler::TRY_CATCH));
346 } else { 398 } else {
347 push(Immediate(StackHandler::TRY_FINALLY)); 399 push(Immediate(StackHandler::TRY_FINALLY));
348 } 400 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // Indicate that code has changed. 875 // Indicate that code has changed.
824 CPU::FlushICache(address_, size_); 876 CPU::FlushICache(address_, size_);
825 877
826 // Check that the code was patched as expected. 878 // Check that the code was patched as expected.
827 ASSERT(masm_.pc_ == address_ + size_); 879 ASSERT(masm_.pc_ == address_ + size_);
828 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 880 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
829 } 881 }
830 882
831 883
832 } } // namespace v8::internal 884 } } // namespace v8::internal
OLDNEW
« src/codegen-ia32.cc ('K') | « src/macro-assembler-ia32.h ('k') | src/stub-cache-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698