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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2375953002: [regexp] Port RegExp.prototype.exec to TurboFan (Closed)
Patch Set: Handle smi this values Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-stub-assembler.h" 5 #include "src/code-stub-assembler.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/frames-inl.h" 7 #include "src/frames-inl.h"
8 #include "src/frames.h" 8 #include "src/frames.h"
9 #include "src/ic/handler-configuration.h" 9 #include "src/ic/handler-configuration.h"
10 #include "src/ic/stub-cache.h" 10 #include "src/ic/stub-cache.h"
(...skipping 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 CallRuntime(Runtime::kThrowNotGeneric, context, 2222 CallRuntime(Runtime::kThrowNotGeneric, context,
2223 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, 2223 HeapConstant(factory()->NewStringFromAsciiChecked(method_name,
2224 TENURED))); 2224 TENURED)));
2225 Goto(&done_loop); // Never reached. 2225 Goto(&done_loop); // Never reached.
2226 } 2226 }
2227 2227
2228 Bind(&done_loop); 2228 Bind(&done_loop);
2229 return var_value.value(); 2229 return var_value.value();
2230 } 2230 }
2231 2231
2232 Node* CodeStubAssembler::ThrowIfNotType(Node* context, Node* value,
2233 int instance_type,
Igor Sheludko 2016/09/29 12:55:29 Same here.
jgruber 2016/09/29 14:40:27 Done.
2234 char const* method_name) {
2235 Label out(this), throw_exception(this, Label::kDeferred);
2236 Variable var_value_map(this, MachineType::PointerRepresentation());
Igor Sheludko 2016/09/29 12:55:29 MachineRepresentation::kTagged
jgruber 2016/09/29 14:40:27 Done.
2237
2238 GotoIf(WordIsSmi(value), &throw_exception);
2239
2240 // Load the instance type of the {value}.
2241 var_value_map.Bind(LoadMap(value));
2242 Node* const value_instance_type = LoadMapInstanceType(var_value_map.value());
2243
2244 Branch(Word32Equal(value_instance_type, Int32Constant(instance_type)), &out,
2245 &throw_exception);
2246
2247 // The {value} is not a compatible receiver for this method.
2248 Bind(&throw_exception);
2249 CallRuntime(
2250 Runtime::kThrowIncompatibleMethodReceiver, context,
2251 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, TENURED)),
2252 value);
2253 var_value_map.Bind(UndefinedConstant());
2254 Goto(&out); // Never reached.
2255
2256 Bind(&out);
2257 return var_value_map.value();
2258 }
2259
2232 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { 2260 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) {
2233 // Translate the {index} into a Word. 2261 // Translate the {index} into a Word.
2234 index = SmiToWord(index); 2262 index = SmiToWord(index);
2235 2263
2236 // We may need to loop in case of cons or sliced strings. 2264 // We may need to loop in case of cons or sliced strings.
2237 Variable var_index(this, MachineType::PointerRepresentation()); 2265 Variable var_index(this, MachineType::PointerRepresentation());
2238 Variable var_result(this, MachineRepresentation::kWord32); 2266 Variable var_result(this, MachineRepresentation::kWord32);
2239 Variable var_string(this, MachineRepresentation::kTagged); 2267 Variable var_string(this, MachineRepresentation::kTagged);
2240 Variable* loop_vars[] = {&var_index, &var_string}; 2268 Variable* loop_vars[] = {&var_index, &var_string};
2241 Label done_loop(this, &var_result), loop(this, 2, loop_vars); 2269 Label done_loop(this, &var_result), loop(this, 2, loop_vars);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 // Check if the {string} is an ExternalString. 2357 // Check if the {string} is an ExternalString.
2330 Label if_stringisexternal(this), if_stringisnotexternal(this); 2358 Label if_stringisexternal(this), if_stringisnotexternal(this);
2331 Branch(Word32Equal(Word32And(string_instance_type, 2359 Branch(Word32Equal(Word32And(string_instance_type,
2332 Int32Constant(kStringRepresentationMask)), 2360 Int32Constant(kStringRepresentationMask)),
2333 Int32Constant(kExternalStringTag)), 2361 Int32Constant(kExternalStringTag)),
2334 &if_stringisexternal, &if_stringisnotexternal); 2362 &if_stringisexternal, &if_stringisnotexternal);
2335 2363
2336 Bind(&if_stringisexternal); 2364 Bind(&if_stringisexternal);
2337 { 2365 {
2338 // Check if the {string} is a short external string. 2366 // Check if the {string} is a short external string.
2339 Label if_stringisshort(this), 2367 Label if_stringisnotshort(this),
Igor Sheludko 2016/09/29 12:55:29 I guess this renaming should be part of substr CL.
jgruber 2016/09/29 14:40:27 How come? It's unrelated to both - I'll just split
Igor Sheludko 2016/09/29 15:01:34 Ok.
2340 if_stringisnotshort(this, Label::kDeferred); 2368 if_stringisshort(this, Label::kDeferred);
2341 Branch(Word32Equal(Word32And(string_instance_type, 2369 Branch(Word32Equal(Word32And(string_instance_type,
2342 Int32Constant(kShortExternalStringMask)), 2370 Int32Constant(kShortExternalStringMask)),
2343 Int32Constant(0)), 2371 Int32Constant(0)),
2344 &if_stringisshort, &if_stringisnotshort); 2372 &if_stringisnotshort, &if_stringisshort);
2345 2373
2346 Bind(&if_stringisshort); 2374 Bind(&if_stringisnotshort);
2347 { 2375 {
2348 // Load the actual resource data from the {string}. 2376 // Load the actual resource data from the {string}.
2349 Node* string_resource_data = 2377 Node* string_resource_data =
2350 LoadObjectField(string, ExternalString::kResourceDataOffset, 2378 LoadObjectField(string, ExternalString::kResourceDataOffset,
2351 MachineType::Pointer()); 2379 MachineType::Pointer());
2352 2380
2353 // Check if the {string} is a TwoByteExternalString or a 2381 // Check if the {string} is a TwoByteExternalString or a
2354 // OneByteExternalString. 2382 // OneByteExternalString.
2355 Label if_stringistwobyte(this), if_stringisonebyte(this); 2383 Label if_stringistwobyte(this), if_stringisonebyte(this);
2356 Branch(Word32Equal(Word32And(string_instance_type, 2384 Branch(Word32Equal(Word32And(string_instance_type,
2357 Int32Constant(kStringEncodingMask)), 2385 Int32Constant(kStringEncodingMask)),
2358 Int32Constant(kTwoByteStringTag)), 2386 Int32Constant(kTwoByteStringTag)),
2359 &if_stringistwobyte, &if_stringisonebyte); 2387 &if_stringistwobyte, &if_stringisonebyte);
2360 2388
2361 Bind(&if_stringisonebyte); 2389 Bind(&if_stringisonebyte);
2362 { 2390 {
2363 var_result.Bind( 2391 var_result.Bind(
2364 Load(MachineType::Uint8(), string_resource_data, index)); 2392 Load(MachineType::Uint8(), string_resource_data, index));
2365 Goto(&done_loop); 2393 Goto(&done_loop);
2366 } 2394 }
2367 2395
2368 Bind(&if_stringistwobyte); 2396 Bind(&if_stringistwobyte);
2369 { 2397 {
2370 var_result.Bind(Load(MachineType::Uint16(), string_resource_data, 2398 var_result.Bind(Load(MachineType::Uint16(), string_resource_data,
2371 WordShl(index, IntPtrConstant(1)))); 2399 WordShl(index, IntPtrConstant(1))));
2372 Goto(&done_loop); 2400 Goto(&done_loop);
2373 } 2401 }
2374 } 2402 }
2375 2403
2376 Bind(&if_stringisnotshort); 2404 Bind(&if_stringisshort);
2377 { 2405 {
2378 // The {string} might be compressed, call the runtime. 2406 // The {string} might be compressed, call the runtime.
2379 var_result.Bind(SmiToWord32( 2407 var_result.Bind(SmiToWord32(
2380 CallRuntime(Runtime::kExternalStringGetChar, 2408 CallRuntime(Runtime::kExternalStringGetChar,
2381 NoContextConstant(), string, SmiTag(index)))); 2409 NoContextConstant(), string, SmiTag(index))));
2382 Goto(&done_loop); 2410 Goto(&done_loop);
2383 } 2411 }
2384 } 2412 }
2385 2413
2386 Bind(&if_stringisnotexternal); 2414 Bind(&if_stringisnotexternal);
(...skipping 3307 matching lines...) Expand 10 before | Expand all | Expand 10 after
5694 Heap::kTheHoleValueRootIndex); 5722 Heap::kTheHoleValueRootIndex);
5695 5723
5696 // Store the WeakCell in the feedback vector. 5724 // Store the WeakCell in the feedback vector.
5697 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 5725 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
5698 CodeStubAssembler::SMI_PARAMETERS); 5726 CodeStubAssembler::SMI_PARAMETERS);
5699 return cell; 5727 return cell;
5700 } 5728 }
5701 5729
5702 } // namespace internal 5730 } // namespace internal
5703 } // namespace v8 5731 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698