x86-64

Array bounds checks on 64-bit hardware using hardware memory-protection

北城以北 提交于 2019-12-03 11:19:48
问题 I was reading a blog on 64-bit Firefox edition on hacks.mozilla.org. The author states: For asm.js code, the increased address space also lets us use hardware memory protection to safely remove bounds checks from asm.js heap accesses. The gains are pretty dramatic: 8%-17% on the asmjs-apps-*-throughput tests as reported on arewefastyet.com. I was trying to understand how 64-bit hardware have automatic bounds check (assuming compiler does with hardware support) for C/C++. I could not find any

Why does loop alignment on 32 byte make code faster?

点点圈 提交于 2019-12-03 11:07:30
Look at this code: one.cpp: bool test(int a, int b, int c, int d); int main() { volatile int va = 1; volatile int vb = 2; volatile int vc = 3; volatile int vd = 4; int a = va; int b = vb; int c = vc; int d = vd; int s = 0; __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); __asm__("nop"); for (int i=0; i<2000000000; i++) { s += test(a, b, c, d); } return s; } two.cpp: bool test(int a, int b, int c, int d) {

Is it possible to run x86 assembly on a x64 operating system?

别来无恙 提交于 2019-12-03 10:27:33
问题 Recently I decided that it was worth getting a try on basic x86 assembly so that it would be easier to debug programs, etc, etc. So I started (about a week ago) learning x86 assembly, in that time, I upgraded my computer to 8GB ram, so obviusly my x86 Windows XP installation was wasting up all that memory, now, I'm running a x64 Windows 7 copy, so the question is: Is it possible to work with x86 assembly on a x64 operating system? Will it run properly in the emulator? Or should I learn x64

How are interrupts handled on SMP?

血红的双手。 提交于 2019-12-03 09:34:24
How are interrupts handled on SMP (Symmeteric multiprocessor/multicore) machines? Is there only one memory management unit or more? Say two threads, A and B running on different cores touch a memory page (at the same time) which is not there in the page table, in which case there will be a page fault and a new page is brought in from the memory. What is the sequence of events which will happen? If there is one memory management unit, to which core is the page fault forwarded to? How does the kernel handle it? Are there multiple instances of the kernel, each one running on a different core? If

Why does the iOS simulator require i386 and x86_64 symbols even though I'm on an x86_64 system only?

折月煮酒 提交于 2019-12-03 09:28:48
问题 I'm trying to get an app running on the simulator that has had some problems doing so before. We don't have libjpeg.a built for i386 , but it does have x86_64 . This is the only dependency left, but I'm wondering why I actually need i386 symbols, if I'm running on an x86_64 mac. 回答1: The iOS simulator can run your app in 32 and 64-bit modes. This is allows you to work out a lot of 64-bit issues and make sure it is ready for both armv7 and arm64. To do this, it compiles your app for i386 and

GCC/Clang x86_64 C++ ABI mismatch when returning a tuple?

时光毁灭记忆、已成空白 提交于 2019-12-03 09:22:34
问题 When trying to optimize return values on x86_64, I noticed a strange thing. Namely, given the code: #include <cstdint> #include <tuple> #include <utility> using namespace std; constexpr uint64_t a = 1u; constexpr uint64_t b = 2u; pair<uint64_t, uint64_t> f() { return {a, b}; } tuple<uint64_t, uint64_t> g() { return tuple<uint64_t, uint64_t>{a, b}; } Clang 3.8 outputs this assembly code for f : movl $1, %eax movl $2, %edx retq and this for g : movl $2, %eax movl $1, %edx retq which look

32-bit pointers with the x86-64 ISA: why not?

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The x86-64 instruction set adds more registers and other improvements to help streamline executable code. However, in many applications the increased pointer size is a burden. The extra, unused bytes in every pointer clog up the cache and might even overflow RAM. GCC, for example, builds with the -m32 flag, and I assume this is the reason. It's possible to load a 32-bit value and treat it as a pointer. This doesn't necessitate extra instructions, just load/compute the 32 bits and load from the resulting address. The trick won't be portable,

VirtualBox - Kernel requires an x86-64 cpu but only detected an i686 cpu

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Intel i5-2410M CPU running at 2.30 GHz running a Windows 7 64-bit operating system. I have VirtualBox 4.13 installed. I am trying to run ubuntu-14.04-desktop-amd64.iso but I get an error this kernel requires an x86-64 cpu but only detected an i686 cpu I even enabled the Intel Virtualization in the BIOS settings and then tried to use the image again but I still get the same error. Is there any other reason why I can't use the image? 回答1: My best guess is that you somehow configured the VM for 32 bit execution instead of 64. Can you share the

x86_64 align stack and recover without saving registers

大憨熊 提交于 2019-12-03 08:21:37
I'm writing interrupt handling routines for x86_64. The ABI specifies that before calling a C function I must align the stack to 16 bytes. The x86_64 ISA specifies that on entry to an ISR, my stack is 8 byte aligned. I need to align my stack pointer to 16 bytes therefore. The issue is that on return from my C function, I must recover the (potentially) unaligned stack pointer so that I can return from my interrupt correctly. I wonder if there is a way to do this without using a general purpose register? Here's my solution to the question as put: pushq %rsp pushq (%rsp) andq $-0x10, %rsp call

What is the difference between assembly on mac and assembly on linux?

ぐ巨炮叔叔 提交于 2019-12-03 07:20:43
问题 I've been trying to get familiar with assembly on mac, and from what I can tell, the documentation is really sparse, and most books on the subject are for windows or linux. I thought I would be able to translate from linux to mac pretty easily, however this (linux) .file "simple.c" .text .globl simple .type simple, @function simple: pushl %ebp movl %esp, %ebp movl 8(%ebp), %edx movl 12(%ebp), %eax addl (%edx), %eax movl %eax, (%edx) popl %ebp ret .size simple, .-simple .ident "GCC: (Ubuntu 4