OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 __ movq(prototype, Operand(prototype, Context::SlotOffset(index))); | 208 __ movq(prototype, Operand(prototype, Context::SlotOffset(index))); |
209 // Load the initial map. The global functions all have initial maps. | 209 // Load the initial map. The global functions all have initial maps. |
210 __ movq(prototype, | 210 __ movq(prototype, |
211 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); | 211 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); |
212 // Load the prototype from the initial map. | 212 // Load the prototype from the initial map. |
213 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 213 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
214 } | 214 } |
215 | 215 |
216 | 216 |
217 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( | 217 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
218 MacroAssembler* masm, int index, Register prototype) { | 218 MacroAssembler* masm, int index, Register prototype, Label* miss) { |
| 219 // Check we're still in the same context. |
| 220 __ Move(prototype, Top::global()); |
| 221 __ cmpq(Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)), |
| 222 prototype); |
| 223 __ j(not_equal, miss); |
219 // Get the global function with the given index. | 224 // Get the global function with the given index. |
220 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); | 225 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); |
221 // Load its initial map. The global functions all have initial maps. | 226 // Load its initial map. The global functions all have initial maps. |
222 __ Move(prototype, Handle<Map>(function->initial_map())); | 227 __ Move(prototype, Handle<Map>(function->initial_map())); |
223 // Load the prototype from the initial map. | 228 // Load the prototype from the initial map. |
224 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 229 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
225 } | 230 } |
226 | 231 |
227 | 232 |
228 // Load a fast property out of a holder object (src). In-object properties | 233 // Load a fast property out of a holder object (src). In-object properties |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 case STRING_CHECK: | 908 case STRING_CHECK: |
904 if (!function->IsBuiltin()) { | 909 if (!function->IsBuiltin()) { |
905 // Calling non-builtins with a value as receiver requires boxing. | 910 // Calling non-builtins with a value as receiver requires boxing. |
906 __ jmp(&miss); | 911 __ jmp(&miss); |
907 } else { | 912 } else { |
908 // Check that the object is a two-byte string or a symbol. | 913 // Check that the object is a two-byte string or a symbol. |
909 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax); | 914 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax); |
910 __ j(above_equal, &miss); | 915 __ j(above_equal, &miss); |
911 // Check that the maps starting from the prototype haven't changed. | 916 // Check that the maps starting from the prototype haven't changed. |
912 GenerateDirectLoadGlobalFunctionPrototype( | 917 GenerateDirectLoadGlobalFunctionPrototype( |
913 masm(), Context::STRING_FUNCTION_INDEX, rax); | 918 masm(), Context::STRING_FUNCTION_INDEX, rax, &miss); |
914 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, | 919 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, |
915 rbx, rdx, rdi, name, &miss); | 920 rbx, rdx, rdi, name, &miss); |
916 } | 921 } |
917 break; | 922 break; |
918 | 923 |
919 case NUMBER_CHECK: { | 924 case NUMBER_CHECK: { |
920 if (!function->IsBuiltin()) { | 925 if (!function->IsBuiltin()) { |
921 // Calling non-builtins with a value as receiver requires boxing. | 926 // Calling non-builtins with a value as receiver requires boxing. |
922 __ jmp(&miss); | 927 __ jmp(&miss); |
923 } else { | 928 } else { |
924 Label fast; | 929 Label fast; |
925 // Check that the object is a smi or a heap number. | 930 // Check that the object is a smi or a heap number. |
926 __ JumpIfSmi(rdx, &fast); | 931 __ JumpIfSmi(rdx, &fast); |
927 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax); | 932 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax); |
928 __ j(not_equal, &miss); | 933 __ j(not_equal, &miss); |
929 __ bind(&fast); | 934 __ bind(&fast); |
930 // Check that the maps starting from the prototype haven't changed. | 935 // Check that the maps starting from the prototype haven't changed. |
931 GenerateDirectLoadGlobalFunctionPrototype( | 936 GenerateDirectLoadGlobalFunctionPrototype( |
932 masm(), Context::NUMBER_FUNCTION_INDEX, rax); | 937 masm(), Context::NUMBER_FUNCTION_INDEX, rax, &miss); |
933 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, | 938 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, |
934 rbx, rdx, rdi, name, &miss); | 939 rbx, rdx, rdi, name, &miss); |
935 } | 940 } |
936 break; | 941 break; |
937 } | 942 } |
938 | 943 |
939 case BOOLEAN_CHECK: { | 944 case BOOLEAN_CHECK: { |
940 if (!function->IsBuiltin()) { | 945 if (!function->IsBuiltin()) { |
941 // Calling non-builtins with a value as receiver requires boxing. | 946 // Calling non-builtins with a value as receiver requires boxing. |
942 __ jmp(&miss); | 947 __ jmp(&miss); |
943 } else { | 948 } else { |
944 Label fast; | 949 Label fast; |
945 // Check that the object is a boolean. | 950 // Check that the object is a boolean. |
946 __ CompareRoot(rdx, Heap::kTrueValueRootIndex); | 951 __ CompareRoot(rdx, Heap::kTrueValueRootIndex); |
947 __ j(equal, &fast); | 952 __ j(equal, &fast); |
948 __ CompareRoot(rdx, Heap::kFalseValueRootIndex); | 953 __ CompareRoot(rdx, Heap::kFalseValueRootIndex); |
949 __ j(not_equal, &miss); | 954 __ j(not_equal, &miss); |
950 __ bind(&fast); | 955 __ bind(&fast); |
951 // Check that the maps starting from the prototype haven't changed. | 956 // Check that the maps starting from the prototype haven't changed. |
952 GenerateDirectLoadGlobalFunctionPrototype( | 957 GenerateDirectLoadGlobalFunctionPrototype( |
953 masm(), Context::BOOLEAN_FUNCTION_INDEX, rax); | 958 masm(), Context::BOOLEAN_FUNCTION_INDEX, rax, &miss); |
954 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, | 959 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, |
955 rbx, rdx, rdi, name, &miss); | 960 rbx, rdx, rdi, name, &miss); |
956 } | 961 } |
957 break; | 962 break; |
958 } | 963 } |
959 | 964 |
960 default: | 965 default: |
961 UNREACHABLE(); | 966 UNREACHABLE(); |
962 } | 967 } |
963 | 968 |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2551 // Return the generated code. | 2556 // Return the generated code. |
2552 return GetCode(); | 2557 return GetCode(); |
2553 } | 2558 } |
2554 | 2559 |
2555 | 2560 |
2556 #undef __ | 2561 #undef __ |
2557 | 2562 |
2558 } } // namespace v8::internal | 2563 } } // namespace v8::internal |
2559 | 2564 |
2560 #endif // V8_TARGET_ARCH_X64 | 2565 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |