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

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

Issue 2195863002: [turbofan] Stub for typeof operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Delete now unused untemplated DoUnaryOp Created 4 years, 4 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/code-stubs.cc ('k') | src/crankshaft/arm/lithium-codegen-arm.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 // 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-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/crankshaft/hydrogen.h" 10 #include "src/crankshaft/hydrogen.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 HValue* number = GetParameter(Descriptor::kArgument); 336 HValue* number = GetParameter(Descriptor::kArgument);
337 return BuildNumberToString(number, Type::Number()); 337 return BuildNumberToString(number, Type::Number());
338 } 338 }
339 339
340 340
341 Handle<Code> NumberToStringStub::GenerateCode() { 341 Handle<Code> NumberToStringStub::GenerateCode() {
342 return DoGenerateCode(this); 342 return DoGenerateCode(this);
343 } 343 }
344 344
345 345
346 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47).
347 template <>
348 HValue* CodeStubGraphBuilder<TypeofStub>::BuildCodeStub() {
349 Factory* factory = isolate()->factory();
350 HConstant* number_string = Add<HConstant>(factory->number_string());
351 HValue* object = GetParameter(Descriptor::kObject);
352
353 IfBuilder is_smi(this);
354 HValue* smi_check = is_smi.If<HIsSmiAndBranch>(object);
355 is_smi.Then();
356 { Push(number_string); }
357 is_smi.Else();
358 {
359 IfBuilder is_number(this);
360 is_number.If<HCompareMap>(object, isolate()->factory()->heap_number_map());
361 is_number.Then();
362 { Push(number_string); }
363 is_number.Else();
364 {
365 HValue* map = AddLoadMap(object, smi_check);
366 HValue* instance_type = Add<HLoadNamedField>(
367 map, nullptr, HObjectAccess::ForMapInstanceType());
368 IfBuilder is_string(this);
369 is_string.If<HCompareNumericAndBranch>(
370 instance_type, Add<HConstant>(FIRST_NONSTRING_TYPE), Token::LT);
371 is_string.Then();
372 { Push(Add<HConstant>(factory->string_string())); }
373 is_string.Else();
374 {
375 HConstant* object_string = Add<HConstant>(factory->object_string());
376 IfBuilder is_oddball(this);
377 is_oddball.If<HCompareNumericAndBranch>(
378 instance_type, Add<HConstant>(ODDBALL_TYPE), Token::EQ);
379 is_oddball.Then();
380 {
381 Push(Add<HLoadNamedField>(object, nullptr,
382 HObjectAccess::ForOddballTypeOf()));
383 }
384 is_oddball.Else();
385 {
386 IfBuilder is_symbol(this);
387 is_symbol.If<HCompareNumericAndBranch>(
388 instance_type, Add<HConstant>(SYMBOL_TYPE), Token::EQ);
389 is_symbol.Then();
390 { Push(Add<HConstant>(factory->symbol_string())); }
391 is_symbol.Else();
392 {
393 HValue* bit_field = Add<HLoadNamedField>(
394 map, nullptr, HObjectAccess::ForMapBitField());
395 HValue* bit_field_masked = AddUncasted<HBitwise>(
396 Token::BIT_AND, bit_field,
397 Add<HConstant>((1 << Map::kIsCallable) |
398 (1 << Map::kIsUndetectable)));
399 IfBuilder is_function(this);
400 is_function.If<HCompareNumericAndBranch>(
401 bit_field_masked, Add<HConstant>(1 << Map::kIsCallable),
402 Token::EQ);
403 is_function.Then();
404 { Push(Add<HConstant>(factory->function_string())); }
405 is_function.Else();
406 {
407 #define SIMD128_BUILDER_OPEN(TYPE, Type, type, lane_count, lane_type) \
408 IfBuilder is_##type(this); \
409 is_##type.If<HCompareObjectEqAndBranch>( \
410 map, Add<HConstant>(factory->type##_map())); \
411 is_##type.Then(); \
412 { Push(Add<HConstant>(factory->type##_string())); } \
413 is_##type.Else(); {
414 SIMD128_TYPES(SIMD128_BUILDER_OPEN)
415 #undef SIMD128_BUILDER_OPEN
416 // Is it an undetectable object?
417 IfBuilder is_undetectable(this);
418 is_undetectable.If<HCompareNumericAndBranch>(
419 bit_field_masked, graph()->GetConstant0(), Token::NE);
420 is_undetectable.Then();
421 {
422 // typeof an undetectable object is 'undefined'.
423 Push(Add<HConstant>(factory->undefined_string()));
424 }
425 is_undetectable.Else();
426 {
427 // For any kind of object not handled above, the spec rule for
428 // host objects gives that it is okay to return "object".
429 Push(object_string);
430 }
431 #define SIMD128_BUILDER_CLOSE(TYPE, Type, type, lane_count, lane_type) }
432 SIMD128_TYPES(SIMD128_BUILDER_CLOSE)
433 #undef SIMD128_BUILDER_CLOSE
434 }
435 is_function.End();
436 }
437 is_symbol.End();
438 }
439 is_oddball.End();
440 }
441 is_string.End();
442 }
443 is_number.End();
444 }
445 is_smi.End();
446
447 return environment()->Pop();
448 }
449
450
451 Handle<Code> TypeofStub::GenerateCode() { return DoGenerateCode(this); }
452
453
454 template <> 346 template <>
455 HValue* CodeStubGraphBuilder<FastCloneRegExpStub>::BuildCodeStub() { 347 HValue* CodeStubGraphBuilder<FastCloneRegExpStub>::BuildCodeStub() {
456 HValue* closure = GetParameter(Descriptor::kClosure); 348 HValue* closure = GetParameter(Descriptor::kClosure);
457 HValue* literal_index = GetParameter(Descriptor::kLiteralIndex); 349 HValue* literal_index = GetParameter(Descriptor::kLiteralIndex);
458 350
459 // This stub is very performance sensitive, the generated code must be tuned 351 // This stub is very performance sensitive, the generated code must be tuned
460 // so that it doesn't build and eager frame. 352 // so that it doesn't build and eager frame.
461 info()->MarkMustNotHaveEagerFrame(); 353 info()->MarkMustNotHaveEagerFrame();
462 354
463 HValue* literals_array = Add<HLoadNamedField>( 355 HValue* literals_array = Add<HLoadNamedField>(
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 return Pop(); 2039 return Pop();
2148 } 2040 }
2149 2041
2150 2042
2151 Handle<Code> KeyedLoadGenericStub::GenerateCode() { 2043 Handle<Code> KeyedLoadGenericStub::GenerateCode() {
2152 return DoGenerateCode(this); 2044 return DoGenerateCode(this);
2153 } 2045 }
2154 2046
2155 } // namespace internal 2047 } // namespace internal
2156 } // namespace v8 2048 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/crankshaft/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698