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

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

Issue 1637015: Add stack alignment check to ia32 and x64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 8 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
« no previous file with comments | « src/x64/macro-assembler-x64.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 void MacroAssembler::Check(Condition cc, const char* msg) { 285 void MacroAssembler::Check(Condition cc, const char* msg) {
286 Label L; 286 Label L;
287 j(cc, &L); 287 j(cc, &L);
288 Abort(msg); 288 Abort(msg);
289 // will not return here 289 // will not return here
290 bind(&L); 290 bind(&L);
291 } 291 }
292 292
293 293
294 void MacroAssembler::CheckStackAlignment() {
295 int frame_alignment = OS::ActivationFrameAlignment();
296 int frame_alignment_mask = frame_alignment - 1;
297 if (frame_alignment > kPointerSize) {
298 ASSERT(IsPowerOf2(frame_alignment));
299 Label alignment_as_expected;
300 testq(rsp, Immediate(frame_alignment_mask));
301 j(zero, &alignment_as_expected);
302 // Abort if stack is not aligned.
303 int3();
304 bind(&alignment_as_expected);
305 }
306 }
307
308
294 void MacroAssembler::NegativeZeroTest(Register result, 309 void MacroAssembler::NegativeZeroTest(Register result,
295 Register op, 310 Register op,
296 Label* then_label) { 311 Label* then_label) {
297 Label ok; 312 Label ok;
298 testl(result, result); 313 testl(result, result);
299 j(not_zero, &ok); 314 j(not_zero, &ok);
300 testl(op, op); 315 testl(op, op);
301 j(sign, then_label); 316 j(sign, then_label);
302 bind(&ok); 317 bind(&ok);
303 } 318 }
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 2636
2622 2637
2623 void MacroAssembler::CallCFunction(ExternalReference function, 2638 void MacroAssembler::CallCFunction(ExternalReference function,
2624 int num_arguments) { 2639 int num_arguments) {
2625 movq(rax, function); 2640 movq(rax, function);
2626 CallCFunction(rax, num_arguments); 2641 CallCFunction(rax, num_arguments);
2627 } 2642 }
2628 2643
2629 2644
2630 void MacroAssembler::CallCFunction(Register function, int num_arguments) { 2645 void MacroAssembler::CallCFunction(Register function, int num_arguments) {
2646 // Check stack alignment.
2647 if (FLAG_debug_code) {
2648 CheckStackAlignment();
2649 }
2650
2631 call(function); 2651 call(function);
2632 ASSERT(OS::ActivationFrameAlignment() != 0); 2652 ASSERT(OS::ActivationFrameAlignment() != 0);
2633 ASSERT(num_arguments >= 0); 2653 ASSERT(num_arguments >= 0);
2634 int argument_slots_on_stack = 2654 int argument_slots_on_stack =
2635 ArgumentStackSlotsForCFunctionCall(num_arguments); 2655 ArgumentStackSlotsForCFunctionCall(num_arguments);
2636 movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize)); 2656 movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize));
2637 } 2657 }
2638 2658
2639 2659
2640 CodePatcher::CodePatcher(byte* address, int size) 2660 CodePatcher::CodePatcher(byte* address, int size)
2641 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { 2661 : address_(address), size_(size), masm_(address, size + Assembler::kGap) {
2642 // Create a new macro assembler pointing to the address of the code to patch. 2662 // Create a new macro assembler pointing to the address of the code to patch.
2643 // The size is adjusted with kGap on order for the assembler to generate size 2663 // The size is adjusted with kGap on order for the assembler to generate size
2644 // bytes of instructions without failing with buffer size constraints. 2664 // bytes of instructions without failing with buffer size constraints.
2645 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2665 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2646 } 2666 }
2647 2667
2648 2668
2649 CodePatcher::~CodePatcher() { 2669 CodePatcher::~CodePatcher() {
2650 // Indicate that code has changed. 2670 // Indicate that code has changed.
2651 CPU::FlushICache(address_, size_); 2671 CPU::FlushICache(address_, size_);
2652 2672
2653 // Check that the code was patched as expected. 2673 // Check that the code was patched as expected.
2654 ASSERT(masm_.pc_ == address_ + size_); 2674 ASSERT(masm_.pc_ == address_ + size_);
2655 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2675 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2656 } 2676 }
2657 2677
2658 } } // namespace v8::internal 2678 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698