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

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 3410014: Fix direct loading of global function prototypes: (Closed)
Patch Set: Added a test for Boolean Created 10 years, 3 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
« no previous file with comments | « src/stub-cache.h ('k') | test/cctest/test-api.cc » ('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 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 __ movq(prototype, Operand(prototype, Context::SlotOffset(index))); 209 __ movq(prototype, Operand(prototype, Context::SlotOffset(index)));
210 // Load the initial map. The global functions all have initial maps. 210 // Load the initial map. The global functions all have initial maps.
211 __ movq(prototype, 211 __ movq(prototype,
212 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); 212 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset));
213 // Load the prototype from the initial map. 213 // Load the prototype from the initial map.
214 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); 214 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset));
215 } 215 }
216 216
217 217
218 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( 218 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
219 MacroAssembler* masm, int index, Register prototype) { 219 MacroAssembler* masm, int index, Register prototype, Label* miss) {
220 // Check we're still in the same context.
221 __ Move(prototype, Top::global());
222 __ cmpq(Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX)),
223 prototype);
224 __ j(not_equal, miss);
220 // Get the global function with the given index. 225 // Get the global function with the given index.
221 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); 226 JSFunction* function = JSFunction::cast(Top::global_context()->get(index));
222 // Load its initial map. The global functions all have initial maps. 227 // Load its initial map. The global functions all have initial maps.
223 __ Move(prototype, Handle<Map>(function->initial_map())); 228 __ Move(prototype, Handle<Map>(function->initial_map()));
224 // Load the prototype from the initial map. 229 // Load the prototype from the initial map.
225 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); 230 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset));
226 } 231 }
227 232
228 233
229 // Load a fast property out of a holder object (src). In-object properties 234 // Load a fast property out of a holder object (src). In-object properties
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 case STRING_CHECK: 962 case STRING_CHECK:
958 if (!function->IsBuiltin()) { 963 if (!function->IsBuiltin()) {
959 // Calling non-builtins with a value as receiver requires boxing. 964 // Calling non-builtins with a value as receiver requires boxing.
960 __ jmp(&miss); 965 __ jmp(&miss);
961 } else { 966 } else {
962 // Check that the object is a two-byte string or a symbol. 967 // Check that the object is a two-byte string or a symbol.
963 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax); 968 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax);
964 __ j(above_equal, &miss); 969 __ j(above_equal, &miss);
965 // Check that the maps starting from the prototype haven't changed. 970 // Check that the maps starting from the prototype haven't changed.
966 GenerateDirectLoadGlobalFunctionPrototype( 971 GenerateDirectLoadGlobalFunctionPrototype(
967 masm(), Context::STRING_FUNCTION_INDEX, rax); 972 masm(), Context::STRING_FUNCTION_INDEX, rax, &miss);
968 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 973 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
969 rbx, rdx, rdi, name, &miss); 974 rbx, rdx, rdi, name, &miss);
970 } 975 }
971 break; 976 break;
972 977
973 case NUMBER_CHECK: { 978 case NUMBER_CHECK: {
974 if (!function->IsBuiltin()) { 979 if (!function->IsBuiltin()) {
975 // Calling non-builtins with a value as receiver requires boxing. 980 // Calling non-builtins with a value as receiver requires boxing.
976 __ jmp(&miss); 981 __ jmp(&miss);
977 } else { 982 } else {
978 Label fast; 983 Label fast;
979 // Check that the object is a smi or a heap number. 984 // Check that the object is a smi or a heap number.
980 __ JumpIfSmi(rdx, &fast); 985 __ JumpIfSmi(rdx, &fast);
981 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax); 986 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax);
982 __ j(not_equal, &miss); 987 __ j(not_equal, &miss);
983 __ bind(&fast); 988 __ bind(&fast);
984 // Check that the maps starting from the prototype haven't changed. 989 // Check that the maps starting from the prototype haven't changed.
985 GenerateDirectLoadGlobalFunctionPrototype( 990 GenerateDirectLoadGlobalFunctionPrototype(
986 masm(), Context::NUMBER_FUNCTION_INDEX, rax); 991 masm(), Context::NUMBER_FUNCTION_INDEX, rax, &miss);
987 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 992 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
988 rbx, rdx, rdi, name, &miss); 993 rbx, rdx, rdi, name, &miss);
989 } 994 }
990 break; 995 break;
991 } 996 }
992 997
993 case BOOLEAN_CHECK: { 998 case BOOLEAN_CHECK: {
994 if (!function->IsBuiltin()) { 999 if (!function->IsBuiltin()) {
995 // Calling non-builtins with a value as receiver requires boxing. 1000 // Calling non-builtins with a value as receiver requires boxing.
996 __ jmp(&miss); 1001 __ jmp(&miss);
997 } else { 1002 } else {
998 Label fast; 1003 Label fast;
999 // Check that the object is a boolean. 1004 // Check that the object is a boolean.
1000 __ CompareRoot(rdx, Heap::kTrueValueRootIndex); 1005 __ CompareRoot(rdx, Heap::kTrueValueRootIndex);
1001 __ j(equal, &fast); 1006 __ j(equal, &fast);
1002 __ CompareRoot(rdx, Heap::kFalseValueRootIndex); 1007 __ CompareRoot(rdx, Heap::kFalseValueRootIndex);
1003 __ j(not_equal, &miss); 1008 __ j(not_equal, &miss);
1004 __ bind(&fast); 1009 __ bind(&fast);
1005 // Check that the maps starting from the prototype haven't changed. 1010 // Check that the maps starting from the prototype haven't changed.
1006 GenerateDirectLoadGlobalFunctionPrototype( 1011 GenerateDirectLoadGlobalFunctionPrototype(
1007 masm(), Context::BOOLEAN_FUNCTION_INDEX, rax); 1012 masm(), Context::BOOLEAN_FUNCTION_INDEX, rax, &miss);
1008 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 1013 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
1009 rbx, rdx, rdi, name, &miss); 1014 rbx, rdx, rdi, name, &miss);
1010 } 1015 }
1011 break; 1016 break;
1012 } 1017 }
1013 1018
1014 default: 1019 default:
1015 UNREACHABLE(); 1020 UNREACHABLE();
1016 } 1021 }
1017 1022
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 const int argc = arguments().immediate(); 1356 const int argc = arguments().immediate();
1352 1357
1353 Label miss; 1358 Label miss;
1354 Label index_out_of_range; 1359 Label index_out_of_range;
1355 1360
1356 GenerateNameCheck(name, &miss); 1361 GenerateNameCheck(name, &miss);
1357 1362
1358 // Check that the maps starting from the prototype haven't changed. 1363 // Check that the maps starting from the prototype haven't changed.
1359 GenerateDirectLoadGlobalFunctionPrototype(masm(), 1364 GenerateDirectLoadGlobalFunctionPrototype(masm(),
1360 Context::STRING_FUNCTION_INDEX, 1365 Context::STRING_FUNCTION_INDEX,
1361 rax); 1366 rax,
1367 &miss);
1362 ASSERT(object != holder); 1368 ASSERT(object != holder);
1363 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 1369 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
1364 rbx, rdx, rdi, name, &miss); 1370 rbx, rdx, rdi, name, &miss);
1365 1371
1366 Register receiver = rax; 1372 Register receiver = rax;
1367 Register index = rdi; 1373 Register index = rdi;
1368 Register scratch1 = rbx; 1374 Register scratch1 = rbx;
1369 Register scratch2 = rdx; 1375 Register scratch2 = rdx;
1370 Register result = rax; 1376 Register result = rax;
1371 __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize)); 1377 __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 1428
1423 const int argc = arguments().immediate(); 1429 const int argc = arguments().immediate();
1424 1430
1425 Label miss; 1431 Label miss;
1426 Label index_out_of_range; 1432 Label index_out_of_range;
1427 GenerateNameCheck(name, &miss); 1433 GenerateNameCheck(name, &miss);
1428 1434
1429 // Check that the maps starting from the prototype haven't changed. 1435 // Check that the maps starting from the prototype haven't changed.
1430 GenerateDirectLoadGlobalFunctionPrototype(masm(), 1436 GenerateDirectLoadGlobalFunctionPrototype(masm(),
1431 Context::STRING_FUNCTION_INDEX, 1437 Context::STRING_FUNCTION_INDEX,
1432 rax); 1438 rax,
1439 &miss);
1433 ASSERT(object != holder); 1440 ASSERT(object != holder);
1434 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 1441 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
1435 rbx, rdx, rdi, name, &miss); 1442 rbx, rdx, rdi, name, &miss);
1436 1443
1437 Register receiver = rbx; 1444 Register receiver = rbx;
1438 Register index = rdi; 1445 Register index = rdi;
1439 Register scratch = rdx; 1446 Register scratch = rdx;
1440 Register result = rax; 1447 Register result = rax;
1441 __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize)); 1448 __ movq(receiver, Operand(rsp, (argc + 1) * kPointerSize));
1442 if (argc > 0) { 1449 if (argc > 0) {
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 // Return the generated code. 2812 // Return the generated code.
2806 return GetCode(); 2813 return GetCode();
2807 } 2814 }
2808 2815
2809 2816
2810 #undef __ 2817 #undef __
2811 2818
2812 } } // namespace v8::internal 2819 } } // namespace v8::internal
2813 2820
2814 #endif // V8_TARGET_ARCH_X64 2821 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698