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

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

Issue 2223003: Fix: make string indexing work with Infinity. (Closed)
Patch Set: Created 10 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
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/string-charat.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 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 10917 matching lines...) Expand 10 before | Expand all | Expand 10 after
10928 // Index is not a smi. 10928 // Index is not a smi.
10929 __ bind(&index_not_smi_); 10929 __ bind(&index_not_smi_);
10930 // If index is a heap number, try converting it to an integer. 10930 // If index is a heap number, try converting it to an integer.
10931 __ CheckMap(index_, Factory::heap_number_map(), index_not_number_, true); 10931 __ CheckMap(index_, Factory::heap_number_map(), index_not_number_, true);
10932 call_helper.BeforeCall(masm); 10932 call_helper.BeforeCall(masm);
10933 __ push(object_); 10933 __ push(object_);
10934 __ push(index_); 10934 __ push(index_);
10935 __ push(result_); 10935 __ push(result_);
10936 __ push(index_); // Consumed by runtime conversion function. 10936 __ push(index_); // Consumed by runtime conversion function.
10937 if (index_flags_ == STRING_INDEX_IS_NUMBER) { 10937 if (index_flags_ == STRING_INDEX_IS_NUMBER) {
10938 // Strictly speaking, NumberToInteger should be called here, but 10938 __ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1);
10939 // our string lengths don't exceed 32 bits and using ToUint32 maps
10940 // -0 to 0, which is what is required by the spec when accessing
10941 // strings.
10942 __ CallRuntime(Runtime::kNumberToJSUint32, 1);
10943 } else { 10939 } else {
10944 ASSERT(index_flags_ == STRING_INDEX_IS_ARRAY_INDEX); 10940 ASSERT(index_flags_ == STRING_INDEX_IS_ARRAY_INDEX);
10945 // NumberToSmi discards numbers that are not exact integers. 10941 // NumberToSmi discards numbers that are not exact integers.
10946 __ CallRuntime(Runtime::kNumberToSmi, 1); 10942 __ CallRuntime(Runtime::kNumberToSmi, 1);
10947 } 10943 }
10948 if (!scratch_.is(rax)) { 10944 if (!scratch_.is(rax)) {
10949 // Save the conversion result before the pop instructions below 10945 // Save the conversion result before the pop instructions below
10950 // have a chance to overwrite it. 10946 // have a chance to overwrite it.
10951 __ movq(scratch_, rax); 10947 __ movq(scratch_, rax);
10952 } 10948 }
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
11878 } 11874 }
11879 11875
11880 #endif 11876 #endif
11881 11877
11882 11878
11883 #undef __ 11879 #undef __
11884 11880
11885 } } // namespace v8::internal 11881 } } // namespace v8::internal
11886 11882
11887 #endif // V8_TARGET_ARCH_X64 11883 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/string-charat.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698