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

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

Issue 548179: Port direct call from JavaScript to native RegExp to x64... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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 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 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) { 1546 void MacroAssembler::CmpInstanceType(Register map, InstanceType type) {
1547 cmpb(FieldOperand(map, Map::kInstanceTypeOffset), 1547 cmpb(FieldOperand(map, Map::kInstanceTypeOffset),
1548 Immediate(static_cast<int8_t>(type))); 1548 Immediate(static_cast<int8_t>(type)));
1549 } 1549 }
1550 1550
1551 1551
1552 Condition MacroAssembler::IsObjectStringType(Register heap_object, 1552 Condition MacroAssembler::IsObjectStringType(Register heap_object,
1553 Register map, 1553 Register map,
1554 Register instance_type) { 1554 Register instance_type) {
1555 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset)); 1555 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset));
1556 movzxbq(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); 1556 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset));
1557 ASSERT(kNotStringTag != 0); 1557 ASSERT(kNotStringTag != 0);
1558 testb(instance_type, Immediate(kIsNotStringMask)); 1558 testb(instance_type, Immediate(kIsNotStringMask));
1559 return zero; 1559 return zero;
1560 } 1560 }
1561 1561
1562 1562
1563 void MacroAssembler::TryGetFunctionPrototype(Register function, 1563 void MacroAssembler::TryGetFunctionPrototype(Register function,
1564 Register result, 1564 Register result,
1565 Label* miss) { 1565 Label* miss) {
1566 // Check that the receiver isn't a smi. 1566 // Check that the receiver isn't a smi.
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 movq(dst, FieldOperand(dst, JSFunction::kContextOffset)); 2466 movq(dst, FieldOperand(dst, JSFunction::kContextOffset));
2467 } 2467 }
2468 // The context may be an intermediate context, not a function context. 2468 // The context may be an intermediate context, not a function context.
2469 movq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); 2469 movq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX)));
2470 } else { // context is the current function context. 2470 } else { // context is the current function context.
2471 // The context may be an intermediate context, not a function context. 2471 // The context may be an intermediate context, not a function context.
2472 movq(dst, Operand(rsi, Context::SlotOffset(Context::FCONTEXT_INDEX))); 2472 movq(dst, Operand(rsi, Context::SlotOffset(Context::FCONTEXT_INDEX)));
2473 } 2473 }
2474 } 2474 }
2475 2475
2476 int MacroAssembler::ArgumentStackSlotsForCFunctionCall(int num_arguments) {
2477 // On Windows stack slots are reserved by the caller for all arguments
2478 // including the ones passed in registers. On Linux 6 arguments are passed in
2479 // registers and the caller does not reserve stack slots for them.
2480 ASSERT(num_arguments >= 0);
2481 #ifdef _WIN64
2482 static const int kArgumentsWithoutStackSlot = 0;
2483 #else
2484 static const int kArgumentsWithoutStackSlot = 6;
2485 #endif
2486 return num_arguments > kArgumentsWithoutStackSlot ?
2487 num_arguments - kArgumentsWithoutStackSlot : 0;
2488 }
2489
2490 void MacroAssembler::PrepareCallCFunction(int num_arguments) {
2491 int frame_alignment = OS::ActivationFrameAlignment();
2492 ASSERT(frame_alignment != 0);
2493 ASSERT(num_arguments >= 0);
2494 // Make stack end at alignment and allocate space for arguments and old rsp.
2495 movq(kScratchRegister, rsp);
2496 ASSERT(IsPowerOf2(frame_alignment));
2497 int argument_slots_on_stack =
2498 ArgumentStackSlotsForCFunctionCall(num_arguments);
2499 subq(rsp, Immediate((argument_slots_on_stack + 1) * kPointerSize));
2500 and_(rsp, Immediate(-frame_alignment));
2501 movq(Operand(rsp, argument_slots_on_stack * kPointerSize), kScratchRegister);
2502 }
2503
2504
2505 void MacroAssembler::CallCFunction(ExternalReference function,
2506 int num_arguments) {
2507 movq(rax, function);
2508 CallCFunction(rax, num_arguments);
2509 }
2510
2511
2512 void MacroAssembler::CallCFunction(Register function, int num_arguments) {
2513 call(function);
2514 ASSERT(OS::ActivationFrameAlignment() != 0);
2515 ASSERT(num_arguments >= 0);
2516 int argument_slots_on_stack =
2517 ArgumentStackSlotsForCFunctionCall(num_arguments);
2518 movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize));
2519 }
2520
2476 2521
2477 CodePatcher::CodePatcher(byte* address, int size) 2522 CodePatcher::CodePatcher(byte* address, int size)
2478 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { 2523 : address_(address), size_(size), masm_(address, size + Assembler::kGap) {
2479 // Create a new macro assembler pointing to the address of the code to patch. 2524 // Create a new macro assembler pointing to the address of the code to patch.
2480 // The size is adjusted with kGap on order for the assembler to generate size 2525 // The size is adjusted with kGap on order for the assembler to generate size
2481 // bytes of instructions without failing with buffer size constraints. 2526 // bytes of instructions without failing with buffer size constraints.
2482 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2527 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2483 } 2528 }
2484 2529
2485 2530
2486 CodePatcher::~CodePatcher() { 2531 CodePatcher::~CodePatcher() {
2487 // Indicate that code has changed. 2532 // Indicate that code has changed.
2488 CPU::FlushICache(address_, size_); 2533 CPU::FlushICache(address_, size_);
2489 2534
2490 // Check that the code was patched as expected. 2535 // Check that the code was patched as expected.
2491 ASSERT(masm_.pc_ == address_ + size_); 2536 ASSERT(masm_.pc_ == address_ + size_);
2492 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2537 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2493 } 2538 }
2494 2539
2495 } } // namespace v8::internal 2540 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698