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

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

Issue 6682025: Crankshaft support for StringCharFromCode. (Closed)
Patch Set: Ports Created 9 years, 9 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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.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 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 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex); 2971 instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex);
2972 if (FLAG_debug_code) { 2972 if (FLAG_debug_code) {
2973 __ AbortIfNotSmi(rax); 2973 __ AbortIfNotSmi(rax);
2974 } 2974 }
2975 __ SmiToInteger32(rax, rax); 2975 __ SmiToInteger32(rax, rax);
2976 __ StoreToSafepointRegisterSlot(result, rax); 2976 __ StoreToSafepointRegisterSlot(result, rax);
2977 __ PopSafepointRegisters(); 2977 __ PopSafepointRegisters();
2978 } 2978 }
2979 2979
2980 2980
2981 void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
2982 class DeferredStringCharFromCode: public LDeferredCode {
2983 public:
2984 DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr)
2985 : LDeferredCode(codegen), instr_(instr) { }
2986 virtual void Generate() { codegen()->DoDeferredStringCharFromCode(instr_); }
2987 private:
2988 LStringCharFromCode* instr_;
2989 };
2990
2991 DeferredStringCharFromCode* deferred =
2992 new DeferredStringCharFromCode(this, instr);
2993
2994 ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
2995 Register char_code = ToRegister(instr->char_code());
2996 Register result = ToRegister(instr->result());
2997 ASSERT(!char_code.is(result));
2998
2999 __ cmpl(char_code, Immediate(String::kMaxAsciiCharCode));
3000 __ j(above, deferred->entry());
3001 __ LoadRoot(result, Heap::kSingleCharacterStringCacheRootIndex);
3002 __ movq(result, FieldOperand(result,
3003 char_code, times_pointer_size,
3004 FixedArray::kHeaderSize));
3005 __ CompareRoot(result, Heap::kUndefinedValueRootIndex);
3006 __ j(equal, deferred->entry());
3007 __ bind(deferred->exit());
3008 }
3009
3010
3011 void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) {
3012 Register char_code = ToRegister(instr->char_code());
3013 Register result = ToRegister(instr->result());
3014
3015 // TODO(3095996): Get rid of this. For now, we need to make the
3016 // result register contain a valid pointer because it is already
3017 // contained in the register pointer map.
3018 __ Set(result, 0);
3019
3020 __ PushSafepointRegisters();
3021 __ Integer32ToSmi(char_code, char_code);
3022 __ push(char_code);
3023 __ CallRuntimeSaveDoubles(Runtime::kCharFromCode);
3024 RecordSafepointWithRegisters(
3025 instr->pointer_map(), 1, Safepoint::kNoDeoptimizationIndex);
3026 __ StoreToSafepointRegisterSlot(result, rax);
3027 __ PopSafepointRegisters();
3028 }
3029
3030
2981 void LCodeGen::DoStringLength(LStringLength* instr) { 3031 void LCodeGen::DoStringLength(LStringLength* instr) {
2982 Register string = ToRegister(instr->string()); 3032 Register string = ToRegister(instr->string());
2983 Register result = ToRegister(instr->result()); 3033 Register result = ToRegister(instr->result());
2984 __ movq(result, FieldOperand(string, String::kLengthOffset)); 3034 __ movq(result, FieldOperand(string, String::kLengthOffset));
2985 } 3035 }
2986 3036
2987 3037
2988 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { 3038 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) {
2989 LOperand* input = instr->InputAt(0); 3039 LOperand* input = instr->InputAt(0);
2990 ASSERT(input->IsRegister() || input->IsStackSlot()); 3040 ASSERT(input->IsRegister() || input->IsStackSlot());
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
3694 RegisterEnvironmentForDeoptimization(environment); 3744 RegisterEnvironmentForDeoptimization(environment);
3695 ASSERT(osr_pc_offset_ == -1); 3745 ASSERT(osr_pc_offset_ == -1);
3696 osr_pc_offset_ = masm()->pc_offset(); 3746 osr_pc_offset_ = masm()->pc_offset();
3697 } 3747 }
3698 3748
3699 #undef __ 3749 #undef __
3700 3750
3701 } } // namespace v8::internal 3751 } } // namespace v8::internal
3702 3752
3703 #endif // V8_TARGET_ARCH_X64 3753 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698