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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 141703018: Turn RegExpConstructResultStub into a HydrogenCodeStub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 years, 10 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/hydrogen-instructions.h ('k') | src/ia32/full-codegen-ia32.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 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 Isolate* isolate, 132 Isolate* isolate,
133 CodeStubInterfaceDescriptor* descriptor) { 133 CodeStubInterfaceDescriptor* descriptor) {
134 static Register registers[] = { edx, ecx }; 134 static Register registers[] = { edx, ecx };
135 descriptor->register_param_count_ = 2; 135 descriptor->register_param_count_ = 2;
136 descriptor->register_params_ = registers; 136 descriptor->register_params_ = registers;
137 descriptor->deoptimization_handler_ = 137 descriptor->deoptimization_handler_ =
138 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure); 138 FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure);
139 } 139 }
140 140
141 141
142 void RegExpConstructResultStub::InitializeInterfaceDescriptor(
143 Isolate* isolate,
144 CodeStubInterfaceDescriptor* descriptor) {
145 static Register registers[] = { ecx, ebx, eax };
146 descriptor->register_param_count_ = 3;
147 descriptor->register_params_ = registers;
148 descriptor->deoptimization_handler_ =
149 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry;
150 }
151
152
142 void LoadFieldStub::InitializeInterfaceDescriptor( 153 void LoadFieldStub::InitializeInterfaceDescriptor(
143 Isolate* isolate, 154 Isolate* isolate,
144 CodeStubInterfaceDescriptor* descriptor) { 155 CodeStubInterfaceDescriptor* descriptor) {
145 static Register registers[] = { edx }; 156 static Register registers[] = { edx };
146 descriptor->register_param_count_ = 1; 157 descriptor->register_param_count_ = 1;
147 descriptor->register_params_ = registers; 158 descriptor->register_params_ = registers;
148 descriptor->deoptimization_handler_ = NULL; 159 descriptor->deoptimization_handler_ = NULL;
149 } 160 }
150 161
151 162
(...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 1974
1964 // (11) Sliced string. Replace subject with parent. Go to (5a). 1975 // (11) Sliced string. Replace subject with parent. Go to (5a).
1965 // Load offset into edi and replace subject string with parent. 1976 // Load offset into edi and replace subject string with parent.
1966 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset)); 1977 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset));
1967 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset)); 1978 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset));
1968 __ jmp(&check_underlying); // Go to (5a). 1979 __ jmp(&check_underlying); // Go to (5a).
1969 #endif // V8_INTERPRETED_REGEXP 1980 #endif // V8_INTERPRETED_REGEXP
1970 } 1981 }
1971 1982
1972 1983
1973 void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
1974 const int kMaxInlineLength = 100;
1975 Label slowcase;
1976 Label done;
1977 __ mov(ebx, Operand(esp, kPointerSize * 3));
1978 __ JumpIfNotSmi(ebx, &slowcase);
1979 __ cmp(ebx, Immediate(Smi::FromInt(kMaxInlineLength)));
1980 __ j(above, &slowcase);
1981 // Smi-tagging is equivalent to multiplying by 2.
1982 STATIC_ASSERT(kSmiTag == 0);
1983 STATIC_ASSERT(kSmiTagSize == 1);
1984 // Allocate RegExpResult followed by FixedArray with size in ebx.
1985 // JSArray: [Map][empty properties][Elements][Length-smi][index][input]
1986 // Elements: [Map][Length][..elements..]
1987 __ Allocate(JSRegExpResult::kSize + FixedArray::kHeaderSize,
1988 times_pointer_size,
1989 ebx, // In: Number of elements as a smi
1990 REGISTER_VALUE_IS_SMI,
1991 eax, // Out: Start of allocation (tagged).
1992 ecx, // Out: End of allocation.
1993 edx, // Scratch register
1994 &slowcase,
1995 TAG_OBJECT);
1996 // eax: Start of allocated area, object-tagged.
1997
1998 // Set JSArray map to global.regexp_result_map().
1999 // Set empty properties FixedArray.
2000 // Set elements to point to FixedArray allocated right after the JSArray.
2001 // Interleave operations for better latency.
2002 __ mov(edx, ContextOperand(esi, Context::GLOBAL_OBJECT_INDEX));
2003 Factory* factory = masm->isolate()->factory();
2004 __ mov(ecx, Immediate(factory->empty_fixed_array()));
2005 __ lea(ebx, Operand(eax, JSRegExpResult::kSize));
2006 __ mov(edx, FieldOperand(edx, GlobalObject::kNativeContextOffset));
2007 __ mov(FieldOperand(eax, JSObject::kElementsOffset), ebx);
2008 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ecx);
2009 __ mov(edx, ContextOperand(edx, Context::REGEXP_RESULT_MAP_INDEX));
2010 __ mov(FieldOperand(eax, HeapObject::kMapOffset), edx);
2011
2012 // Set input, index and length fields from arguments.
2013 __ mov(ecx, Operand(esp, kPointerSize * 1));
2014 __ mov(FieldOperand(eax, JSRegExpResult::kInputOffset), ecx);
2015 __ mov(ecx, Operand(esp, kPointerSize * 2));
2016 __ mov(FieldOperand(eax, JSRegExpResult::kIndexOffset), ecx);
2017 __ mov(ecx, Operand(esp, kPointerSize * 3));
2018 __ mov(FieldOperand(eax, JSArray::kLengthOffset), ecx);
2019
2020 // Fill out the elements FixedArray.
2021 // eax: JSArray.
2022 // ebx: FixedArray.
2023 // ecx: Number of elements in array, as smi.
2024
2025 // Set map.
2026 __ mov(FieldOperand(ebx, HeapObject::kMapOffset),
2027 Immediate(factory->fixed_array_map()));
2028 // Set length.
2029 __ mov(FieldOperand(ebx, FixedArray::kLengthOffset), ecx);
2030 // Fill contents of fixed-array with undefined.
2031 __ SmiUntag(ecx);
2032 __ mov(edx, Immediate(factory->undefined_value()));
2033 __ lea(ebx, FieldOperand(ebx, FixedArray::kHeaderSize));
2034 // Fill fixed array elements with undefined.
2035 // eax: JSArray.
2036 // ecx: Number of elements to fill.
2037 // ebx: Start of elements in FixedArray.
2038 // edx: undefined.
2039 Label loop;
2040 __ test(ecx, ecx);
2041 __ bind(&loop);
2042 __ j(less_equal, &done, Label::kNear); // Jump if ecx is negative or zero.
2043 __ sub(ecx, Immediate(1));
2044 __ mov(Operand(ebx, ecx, times_pointer_size, 0), edx);
2045 __ jmp(&loop);
2046
2047 __ bind(&done);
2048 __ ret(3 * kPointerSize);
2049
2050 __ bind(&slowcase);
2051 __ TailCallRuntime(Runtime::kRegExpConstructResult, 3, 1);
2052 }
2053
2054
2055 static int NegativeComparisonResult(Condition cc) { 1984 static int NegativeComparisonResult(Condition cc) {
2056 ASSERT(cc != equal); 1985 ASSERT(cc != equal);
2057 ASSERT((cc == less) || (cc == less_equal) 1986 ASSERT((cc == less) || (cc == less_equal)
2058 || (cc == greater) || (cc == greater_equal)); 1987 || (cc == greater) || (cc == greater_equal));
2059 return (cc == greater || cc == greater_equal) ? LESS : GREATER; 1988 return (cc == greater || cc == greater_equal) ? LESS : GREATER;
2060 } 1989 }
2061 1990
2062 1991
2063 static void CheckInputType(MacroAssembler* masm, 1992 static void CheckInputType(MacroAssembler* masm,
2064 Register input, 1993 Register input,
(...skipping 3362 matching lines...) Expand 10 before | Expand all | Expand 10 after
5427 restore_context ? 5356 restore_context ?
5428 &context_restore_operand : NULL); 5357 &context_restore_operand : NULL);
5429 } 5358 }
5430 5359
5431 5360
5432 #undef __ 5361 #undef __
5433 5362
5434 } } // namespace v8::internal 5363 } } // namespace v8::internal
5435 5364
5436 #endif // V8_TARGET_ARCH_IA32 5365 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698