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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 6992072: Implement set trap for proxies, and revamp class hierarchy in preparation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Renamed range constants for InstanceType enum. Created 9 years, 6 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 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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); 858 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
859 __ j(equal, &exit); 859 __ j(equal, &exit);
860 Register null_value = rdi; 860 Register null_value = rdi;
861 __ LoadRoot(null_value, Heap::kNullValueRootIndex); 861 __ LoadRoot(null_value, Heap::kNullValueRootIndex);
862 __ cmpq(rax, null_value); 862 __ cmpq(rax, null_value);
863 __ j(equal, &exit); 863 __ j(equal, &exit);
864 864
865 // Convert the object to a JS object. 865 // Convert the object to a JS object.
866 Label convert, done_convert; 866 Label convert, done_convert;
867 __ JumpIfSmi(rax, &convert); 867 __ JumpIfSmi(rax, &convert);
868 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); 868 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx);
869 __ j(above_equal, &done_convert); 869 __ j(above_equal, &done_convert);
870 __ bind(&convert); 870 __ bind(&convert);
871 __ push(rax); 871 __ push(rax);
872 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); 872 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
873 __ bind(&done_convert); 873 __ bind(&done_convert);
874 __ push(rax); 874 __ push(rax);
875 875
876 // Check cache validity in generated code. This is a fast case for 876 // Check cache validity in generated code. This is a fast case for
877 // the JSObject::IsSimpleEnum cache validity checks. If we cannot 877 // the JSObject::IsSimpleEnum cache validity checks. If we cannot
878 // guarantee cache validity, call the runtime system to check cache 878 // guarantee cache validity, call the runtime system to check cache
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 2350
2351 __ JumpIfSmi(rax, if_false); 2351 __ JumpIfSmi(rax, if_false);
2352 __ CompareRoot(rax, Heap::kNullValueRootIndex); 2352 __ CompareRoot(rax, Heap::kNullValueRootIndex);
2353 __ j(equal, if_true); 2353 __ j(equal, if_true);
2354 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); 2354 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
2355 // Undetectable objects behave like undefined when tested with typeof. 2355 // Undetectable objects behave like undefined when tested with typeof.
2356 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), 2356 __ testb(FieldOperand(rbx, Map::kBitFieldOffset),
2357 Immediate(1 << Map::kIsUndetectable)); 2357 Immediate(1 << Map::kIsUndetectable));
2358 __ j(not_zero, if_false); 2358 __ j(not_zero, if_false);
2359 __ movzxbq(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset)); 2359 __ movzxbq(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset));
2360 __ cmpq(rbx, Immediate(FIRST_JS_OBJECT_TYPE)); 2360 __ cmpq(rbx, Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE));
2361 __ j(below, if_false); 2361 __ j(below, if_false);
2362 __ cmpq(rbx, Immediate(LAST_JS_OBJECT_TYPE)); 2362 __ cmpq(rbx, Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE));
2363 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 2363 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2364 Split(below_equal, if_true, if_false, fall_through); 2364 Split(below_equal, if_true, if_false, fall_through);
2365 2365
2366 context()->Plug(if_true, if_false); 2366 context()->Plug(if_true, if_false);
2367 } 2367 }
2368 2368
2369 2369
2370 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) { 2370 void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) {
2371 ASSERT(args->length() == 1); 2371 ASSERT(args->length() == 1);
2372 2372
2373 VisitForAccumulatorValue(args->at(0)); 2373 VisitForAccumulatorValue(args->at(0));
2374 2374
2375 Label materialize_true, materialize_false; 2375 Label materialize_true, materialize_false;
2376 Label* if_true = NULL; 2376 Label* if_true = NULL;
2377 Label* if_false = NULL; 2377 Label* if_false = NULL;
2378 Label* fall_through = NULL; 2378 Label* fall_through = NULL;
2379 context()->PrepareTest(&materialize_true, &materialize_false, 2379 context()->PrepareTest(&materialize_true, &materialize_false,
2380 &if_true, &if_false, &fall_through); 2380 &if_true, &if_false, &fall_through);
2381 2381
2382 __ JumpIfSmi(rax, if_false); 2382 __ JumpIfSmi(rax, if_false);
2383 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rbx); 2383 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rbx);
2384 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 2384 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2385 Split(above_equal, if_true, if_false, fall_through); 2385 Split(above_equal, if_true, if_false, fall_through);
2386 2386
2387 context()->Plug(if_true, if_false); 2387 context()->Plug(if_true, if_false);
2388 } 2388 }
2389 2389
2390 2390
2391 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { 2391 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) {
2392 ASSERT(args->length() == 1); 2392 ASSERT(args->length() == 1);
2393 2393
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 ASSERT(args->length() == 1); 2652 ASSERT(args->length() == 1);
2653 Label done, null, function, non_function_constructor; 2653 Label done, null, function, non_function_constructor;
2654 2654
2655 VisitForAccumulatorValue(args->at(0)); 2655 VisitForAccumulatorValue(args->at(0));
2656 2656
2657 // If the object is a smi, we return null. 2657 // If the object is a smi, we return null.
2658 __ JumpIfSmi(rax, &null); 2658 __ JumpIfSmi(rax, &null);
2659 2659
2660 // Check that the object is a JS object but take special care of JS 2660 // Check that the object is a JS object but take special care of JS
2661 // functions to make sure they have 'Function' as their class. 2661 // functions to make sure they have 'Function' as their class.
2662 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rax); // Map is now in rax. 2662 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rax);
2663 // Map is now in rax.
2663 __ j(below, &null); 2664 __ j(below, &null);
2664 2665
2665 // As long as JS_FUNCTION_TYPE is the last instance type and it is 2666 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and
2666 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for 2667 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after
2667 // LAST_JS_OBJECT_TYPE. 2668 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter.
2668 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); 2669 ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE);
2669 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); 2670 ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE ==
2670 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); 2671 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1);
2671 __ j(equal, &function); 2672 __ CmpInstanceType(rax, FIRST_CALLABLE_SPEC_OBJECT_TYPE);
2673 __ j(above_equal, &function);
2672 2674
2673 // Check if the constructor in the map is a function. 2675 // Check if the constructor in the map is a function.
2674 __ movq(rax, FieldOperand(rax, Map::kConstructorOffset)); 2676 __ movq(rax, FieldOperand(rax, Map::kConstructorOffset));
2675 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); 2677 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
2676 __ j(not_equal, &non_function_constructor); 2678 __ j(not_equal, &non_function_constructor);
2677 2679
2678 // rax now contains the constructor function. Grab the 2680 // rax now contains the constructor function. Grab the
2679 // instance class name from there. 2681 // instance class name from there.
2680 __ movq(rax, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset)); 2682 __ movq(rax, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset));
2681 __ movq(rax, FieldOperand(rax, SharedFunctionInfo::kInstanceClassNameOffset)); 2683 __ movq(rax, FieldOperand(rax, SharedFunctionInfo::kInstanceClassNameOffset));
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
4009 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); 4011 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
4010 __ j(equal, if_true); 4012 __ j(equal, if_true);
4011 __ JumpIfSmi(rax, if_false); 4013 __ JumpIfSmi(rax, if_false);
4012 // Check for undetectable objects => true. 4014 // Check for undetectable objects => true.
4013 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); 4015 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset));
4014 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), 4016 __ testb(FieldOperand(rdx, Map::kBitFieldOffset),
4015 Immediate(1 << Map::kIsUndetectable)); 4017 Immediate(1 << Map::kIsUndetectable));
4016 Split(not_zero, if_true, if_false, fall_through); 4018 Split(not_zero, if_true, if_false, fall_through);
4017 } else if (check->Equals(isolate()->heap()->function_symbol())) { 4019 } else if (check->Equals(isolate()->heap()->function_symbol())) {
4018 __ JumpIfSmi(rax, if_false); 4020 __ JumpIfSmi(rax, if_false);
4019 __ CmpObjectType(rax, FIRST_FUNCTION_CLASS_TYPE, rdx); 4021 __ CmpObjectType(rax, FIRST_CALLABLE_SPEC_OBJECT_TYPE, rdx);
4020 Split(above_equal, if_true, if_false, fall_through); 4022 Split(above_equal, if_true, if_false, fall_through);
4021 } else if (check->Equals(isolate()->heap()->object_symbol())) { 4023 } else if (check->Equals(isolate()->heap()->object_symbol())) {
4022 __ JumpIfSmi(rax, if_false); 4024 __ JumpIfSmi(rax, if_false);
4023 __ CompareRoot(rax, Heap::kNullValueRootIndex); 4025 __ CompareRoot(rax, Heap::kNullValueRootIndex);
4024 __ j(equal, if_true); 4026 __ j(equal, if_true);
4025 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rdx); 4027 __ CmpObjectType(rax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, rdx);
4026 __ j(below, if_false); 4028 __ j(below, if_false);
4027 __ CmpInstanceType(rdx, FIRST_FUNCTION_CLASS_TYPE); 4029 __ CmpInstanceType(rdx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE);
4028 __ j(above_equal, if_false); 4030 __ j(above_equal, if_false);
4029 // Check for undetectable objects => false. 4031 // Check for undetectable objects => false.
4030 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), 4032 __ testb(FieldOperand(rdx, Map::kBitFieldOffset),
4031 Immediate(1 << Map::kIsUndetectable)); 4033 Immediate(1 << Map::kIsUndetectable));
4032 Split(zero, if_true, if_false, fall_through); 4034 Split(zero, if_true, if_false, fall_through);
4033 } else { 4035 } else {
4034 if (if_false != fall_through) __ jmp(if_false); 4036 if (if_false != fall_through) __ jmp(if_false);
4035 } 4037 }
4036 4038
4037 return true; 4039 return true;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
4292 __ ret(0); 4294 __ ret(0);
4293 } 4295 }
4294 4296
4295 4297
4296 #undef __ 4298 #undef __
4297 4299
4298 4300
4299 } } // namespace v8::internal 4301 } } // namespace v8::internal
4300 4302
4301 #endif // V8_TARGET_ARCH_X64 4303 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698