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

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

Issue 8199004: Reimplement Function.prototype.bind. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 9 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
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/mjsunit/function-bind.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 addq(rsp, Immediate(stack_elements * kPointerSize)); 2310 addq(rsp, Immediate(stack_elements * kPointerSize));
2311 } 2311 }
2312 } 2312 }
2313 2313
2314 2314
2315 void MacroAssembler::Test(const Operand& src, Smi* source) { 2315 void MacroAssembler::Test(const Operand& src, Smi* source) {
2316 testl(Operand(src, kIntSize), Immediate(source->value())); 2316 testl(Operand(src, kIntSize), Immediate(source->value()));
2317 } 2317 }
2318 2318
2319 2319
2320 void MacroAssembler::TestBit(const Operand& src, int bits) {
2321 int byte_offset = bits / kBitsPerByte;
2322 int bit_in_byte = bits & (kBitsPerByte - 1);
2323 testb(Operand(src, byte_offset), Immediate(1 << bit_in_byte));
2324 }
2325
2326
2320 void MacroAssembler::Jump(ExternalReference ext) { 2327 void MacroAssembler::Jump(ExternalReference ext) {
2321 LoadAddress(kScratchRegister, ext); 2328 LoadAddress(kScratchRegister, ext);
2322 jmp(kScratchRegister); 2329 jmp(kScratchRegister);
2323 } 2330 }
2324 2331
2325 2332
2326 void MacroAssembler::Jump(Address destination, RelocInfo::Mode rmode) { 2333 void MacroAssembler::Jump(Address destination, RelocInfo::Mode rmode) {
2327 movq(kScratchRegister, destination, rmode); 2334 movq(kScratchRegister, destination, rmode);
2328 jmp(kScratchRegister); 2335 jmp(kScratchRegister);
2329 } 2336 }
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset)); 2866 movq(map, FieldOperand(heap_object, HeapObject::kMapOffset));
2860 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); 2867 movzxbl(instance_type, FieldOperand(map, Map::kInstanceTypeOffset));
2861 STATIC_ASSERT(kNotStringTag != 0); 2868 STATIC_ASSERT(kNotStringTag != 0);
2862 testb(instance_type, Immediate(kIsNotStringMask)); 2869 testb(instance_type, Immediate(kIsNotStringMask));
2863 return zero; 2870 return zero;
2864 } 2871 }
2865 2872
2866 2873
2867 void MacroAssembler::TryGetFunctionPrototype(Register function, 2874 void MacroAssembler::TryGetFunctionPrototype(Register function,
2868 Register result, 2875 Register result,
2869 Label* miss) { 2876 Label* miss,
2877 bool miss_on_bound_function) {
2870 // Check that the receiver isn't a smi. 2878 // Check that the receiver isn't a smi.
2871 testl(function, Immediate(kSmiTagMask)); 2879 testl(function, Immediate(kSmiTagMask));
2872 j(zero, miss); 2880 j(zero, miss);
2873 2881
2874 // Check that the function really is a function. 2882 // Check that the function really is a function.
2875 CmpObjectType(function, JS_FUNCTION_TYPE, result); 2883 CmpObjectType(function, JS_FUNCTION_TYPE, result);
2876 j(not_equal, miss); 2884 j(not_equal, miss);
2877 2885
2886 if (miss_on_bound_function) {
2887 movq(kScratchRegister,
2888 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
2889 // It's not smi-tagged (stored in the top half of a smi-tagged 8-byte
2890 // field).
2891 TestBit(FieldOperand(kScratchRegister,
2892 SharedFunctionInfo::kCompilerHintsOffset),
2893 SharedFunctionInfo::kBoundFunction);
2894 j(not_zero, miss);
2895 }
2896
2878 // Make sure that the function has an instance prototype. 2897 // Make sure that the function has an instance prototype.
2879 Label non_instance; 2898 Label non_instance;
2880 testb(FieldOperand(result, Map::kBitFieldOffset), 2899 testb(FieldOperand(result, Map::kBitFieldOffset),
2881 Immediate(1 << Map::kHasNonInstancePrototype)); 2900 Immediate(1 << Map::kHasNonInstancePrototype));
2882 j(not_zero, &non_instance, Label::kNear); 2901 j(not_zero, &non_instance, Label::kNear);
2883 2902
2884 // Get the prototype or initial map from the function. 2903 // Get the prototype or initial map from the function.
2885 movq(result, 2904 movq(result,
2886 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); 2905 FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
2887 2906
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
4274 4293
4275 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); 4294 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask));
4276 addl(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), length); 4295 addl(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), length);
4277 4296
4278 bind(&done); 4297 bind(&done);
4279 } 4298 }
4280 4299
4281 } } // namespace v8::internal 4300 } } // namespace v8::internal
4282 4301
4283 #endif // V8_TARGET_ARCH_X64 4302 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/mjsunit/function-bind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698