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

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 9073007: Store transitioned JSArray maps in global context (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 8 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
« no previous file with comments | « src/heap.cc ('k') | src/ia32/macro-assembler-ia32.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 // Otherwise the elements backing store is set to the empty FixedArray. 922 // Otherwise the elements backing store is set to the empty FixedArray.
923 static void AllocateEmptyJSArray(MacroAssembler* masm, 923 static void AllocateEmptyJSArray(MacroAssembler* masm,
924 Register array_function, 924 Register array_function,
925 Register result, 925 Register result,
926 Register scratch1, 926 Register scratch1,
927 Register scratch2, 927 Register scratch2,
928 Register scratch3, 928 Register scratch3,
929 Label* gc_required) { 929 Label* gc_required) {
930 const int initial_capacity = JSArray::kPreallocatedArrayElements; 930 const int initial_capacity = JSArray::kPreallocatedArrayElements;
931 STATIC_ASSERT(initial_capacity >= 0); 931 STATIC_ASSERT(initial_capacity >= 0);
932 // Load the initial map from the array function. 932
933 __ mov(scratch1, FieldOperand(array_function, 933 __ LoadGlobalInitialConstructedArrayMap(array_function, scratch2, scratch1);
934 JSFunction::kPrototypeOrInitialMapOffset));
935 934
936 // Allocate the JSArray object together with space for a fixed array with the 935 // Allocate the JSArray object together with space for a fixed array with the
937 // requested elements. 936 // requested elements.
938 int size = JSArray::kSize; 937 int size = JSArray::kSize;
939 if (initial_capacity > 0) { 938 if (initial_capacity > 0) {
940 size += FixedArray::SizeFor(initial_capacity); 939 size += FixedArray::SizeFor(initial_capacity);
941 } 940 }
942 __ AllocateInNewSpace(size, 941 __ AllocateInNewSpace(size,
943 result, 942 result,
944 scratch2, 943 scratch2,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 Register result, 1026 Register result,
1028 Register elements_array, 1027 Register elements_array,
1029 Register elements_array_end, 1028 Register elements_array_end,
1030 Register scratch, 1029 Register scratch,
1031 bool fill_with_hole, 1030 bool fill_with_hole,
1032 Label* gc_required) { 1031 Label* gc_required) {
1033 ASSERT(scratch.is(edi)); // rep stos destination 1032 ASSERT(scratch.is(edi)); // rep stos destination
1034 ASSERT(!fill_with_hole || array_size.is(ecx)); // rep stos count 1033 ASSERT(!fill_with_hole || array_size.is(ecx)); // rep stos count
1035 ASSERT(!fill_with_hole || !result.is(eax)); // result is never eax 1034 ASSERT(!fill_with_hole || !result.is(eax)); // result is never eax
1036 1035
1037 // Load the initial map from the array function. 1036 __ LoadGlobalInitialConstructedArrayMap(array_function,
1038 __ mov(elements_array, 1037 scratch,
1039 FieldOperand(array_function, 1038 elements_array);
1040 JSFunction::kPrototypeOrInitialMapOffset));
1041 1039
1042 // Allocate the JSArray object together with space for a FixedArray with the 1040 // Allocate the JSArray object together with space for a FixedArray with the
1043 // requested elements. 1041 // requested elements.
1044 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 1042 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
1045 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, 1043 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize,
1046 times_half_pointer_size, // array_size is a smi. 1044 times_half_pointer_size, // array_size is a smi.
1047 array_size, 1045 array_size,
1048 result, 1046 result,
1049 elements_array_end, 1047 elements_array_end,
1050 scratch, 1048 scratch,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 // -- eax : argc 1312 // -- eax : argc
1315 // -- esp[0] : return address 1313 // -- esp[0] : return address
1316 // -- esp[4] : last argument 1314 // -- esp[4] : last argument
1317 // ----------------------------------- 1315 // -----------------------------------
1318 Label generic_array_code; 1316 Label generic_array_code;
1319 1317
1320 // Get the InternalArray function. 1318 // Get the InternalArray function.
1321 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, edi); 1319 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, edi);
1322 1320
1323 if (FLAG_debug_code) { 1321 if (FLAG_debug_code) {
1324 // Initial map for the builtin InternalArray function shoud be a map. 1322 // Initial map for the builtin InternalArray function should be a map.
1325 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); 1323 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
1326 // Will both indicate a NULL and a Smi. 1324 // Will both indicate a NULL and a Smi.
1327 __ test(ebx, Immediate(kSmiTagMask)); 1325 __ test(ebx, Immediate(kSmiTagMask));
1328 __ Assert(not_zero, "Unexpected initial map for InternalArray function"); 1326 __ Assert(not_zero, "Unexpected initial map for InternalArray function");
1329 __ CmpObjectType(ebx, MAP_TYPE, ecx); 1327 __ CmpObjectType(ebx, MAP_TYPE, ecx);
1330 __ Assert(equal, "Unexpected initial map for InternalArray function"); 1328 __ Assert(equal, "Unexpected initial map for InternalArray function");
1331 } 1329 }
1332 1330
1333 // Run the native code for the InternalArray function called as a normal 1331 // Run the native code for the InternalArray function called as a normal
1334 // function. 1332 // function.
1335 ArrayNativeCode(masm, false, &generic_array_code); 1333 ArrayNativeCode(masm, false, &generic_array_code);
1336 1334
1337 // Jump to the generic array code in case the specialized code cannot handle 1335 // Jump to the generic internal array code in case the specialized code cannot
1338 // the construction. 1336 // handle the construction.
1339 __ bind(&generic_array_code); 1337 __ bind(&generic_array_code);
1340 Handle<Code> array_code = 1338 Handle<Code> array_code =
1341 masm->isolate()->builtins()->InternalArrayCodeGeneric(); 1339 masm->isolate()->builtins()->InternalArrayCodeGeneric();
1342 __ jmp(array_code, RelocInfo::CODE_TARGET); 1340 __ jmp(array_code, RelocInfo::CODE_TARGET);
1343 } 1341 }
1344 1342
1345 1343
1346 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { 1344 void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
1347 // ----------- S t a t e ------------- 1345 // ----------- S t a t e -------------
1348 // -- eax : argc 1346 // -- eax : argc
1349 // -- esp[0] : return address 1347 // -- esp[0] : return address
1350 // -- esp[4] : last argument 1348 // -- esp[4] : last argument
1351 // ----------------------------------- 1349 // -----------------------------------
1352 Label generic_array_code; 1350 Label generic_array_code;
1353 1351
1354 // Get the Array function. 1352 // Get the Array function.
1355 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, edi); 1353 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, edi);
1356 1354
1357 if (FLAG_debug_code) { 1355 if (FLAG_debug_code) {
1358 // Initial map for the builtin Array function shoud be a map. 1356 // Initial map for the builtin Array function should be a map.
1359 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); 1357 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset));
1360 // Will both indicate a NULL and a Smi. 1358 // Will both indicate a NULL and a Smi.
1361 __ test(ebx, Immediate(kSmiTagMask)); 1359 __ test(ebx, Immediate(kSmiTagMask));
1362 __ Assert(not_zero, "Unexpected initial map for Array function"); 1360 __ Assert(not_zero, "Unexpected initial map for Array function");
1363 __ CmpObjectType(ebx, MAP_TYPE, ecx); 1361 __ CmpObjectType(ebx, MAP_TYPE, ecx);
1364 __ Assert(equal, "Unexpected initial map for Array function"); 1362 __ Assert(equal, "Unexpected initial map for Array function");
1365 } 1363 }
1366 1364
1367 // Run the native code for the Array function called as a normal function. 1365 // Run the native code for the Array function called as a normal function.
1368 ArrayNativeCode(masm, false, &generic_array_code); 1366 ArrayNativeCode(masm, false, &generic_array_code);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1722 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1725 generator.Generate(); 1723 generator.Generate();
1726 } 1724 }
1727 1725
1728 1726
1729 #undef __ 1727 #undef __
1730 } 1728 }
1731 } // namespace v8::internal 1729 } // namespace v8::internal
1732 1730
1733 #endif // V8_TARGET_ARCH_IA32 1731 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698