OLD | NEW |
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/builtins.h" | 5 #include "src/builtins.h" |
6 | 6 |
7 #include "src/api-arguments.h" | 7 #include "src/api-arguments.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 Label if_objectisnotsmi(assembler); | 367 Label if_objectisnotsmi(assembler); |
368 assembler->Branch(assembler->WordIsSmi(object), &return_false, | 368 assembler->Branch(assembler->WordIsSmi(object), &return_false, |
369 &if_objectisnotsmi); | 369 &if_objectisnotsmi); |
370 assembler->Bind(&if_objectisnotsmi); | 370 assembler->Bind(&if_objectisnotsmi); |
371 | 371 |
372 Node* map = assembler->LoadMap(object); | 372 Node* map = assembler->LoadMap(object); |
373 Node* instance_type = assembler->LoadMapInstanceType(map); | 373 Node* instance_type = assembler->LoadMapInstanceType(map); |
374 | 374 |
375 Variable var_index(assembler, MachineRepresentation::kWord32); | 375 Variable var_index(assembler, MachineRepresentation::kWord32); |
376 | 376 |
377 Label if_keyissmi(assembler), if_keyisnotsmi(assembler), | 377 Label keyisindex(assembler), if_iskeyunique(assembler); |
378 keyisindex(assembler); | 378 assembler->TryToName(key, &keyisindex, &var_index, &if_iskeyunique, |
379 assembler->Branch(assembler->WordIsSmi(key), &if_keyissmi, &if_keyisnotsmi); | 379 &call_runtime); |
380 assembler->Bind(&if_keyissmi); | |
381 { | |
382 // Negative smi keys are named properties. Handle in the runtime. | |
383 Label if_keyispositive(assembler); | |
384 assembler->Branch(assembler->WordIsPositiveSmi(key), &if_keyispositive, | |
385 &call_runtime); | |
386 assembler->Bind(&if_keyispositive); | |
387 | 380 |
388 var_index.Bind(assembler->SmiUntag(key)); | |
389 assembler->Goto(&keyisindex); | |
390 } | |
391 | |
392 assembler->Bind(&if_keyisnotsmi); | |
393 | |
394 Node* key_instance_type = assembler->LoadInstanceType(key); | |
395 Label if_iskeyunique(assembler), if_iskeynotsymbol(assembler); | |
396 assembler->Branch( | |
397 assembler->Word32Equal(key_instance_type, | |
398 assembler->Int32Constant(SYMBOL_TYPE)), | |
399 &if_iskeyunique, &if_iskeynotsymbol); | |
400 assembler->Bind(&if_iskeynotsymbol); | |
401 { | |
402 Label if_iskeyinternalized(assembler); | |
403 Node* bits = assembler->WordAnd( | |
404 key_instance_type, | |
405 assembler->Int32Constant(kIsNotStringMask | kIsNotInternalizedMask)); | |
406 assembler->Branch( | |
407 assembler->Word32Equal( | |
408 bits, assembler->Int32Constant(kStringTag | kInternalizedTag)), | |
409 &if_iskeyinternalized, &call_runtime); | |
410 assembler->Bind(&if_iskeyinternalized); | |
411 | |
412 // Check whether the key is an array index passed in as string. Handle | |
413 // uniform with smi keys if so. | |
414 // TODO(verwaest): Also support non-internalized strings. | |
415 Node* hash = assembler->LoadNameHash(key); | |
416 Node* bit = assembler->Word32And( | |
417 hash, assembler->Int32Constant(internal::Name::kIsNotArrayIndexMask)); | |
418 Label if_isarrayindex(assembler); | |
419 assembler->Branch(assembler->Word32Equal(bit, assembler->Int32Constant(0)), | |
420 &if_isarrayindex, &if_iskeyunique); | |
421 assembler->Bind(&if_isarrayindex); | |
422 var_index.Bind( | |
423 assembler->BitFieldDecode<internal::Name::ArrayIndexValueBits>(hash)); | |
424 assembler->Goto(&keyisindex); | |
425 } | |
426 assembler->Bind(&if_iskeyunique); | 381 assembler->Bind(&if_iskeyunique); |
427 | 382 assembler->TryLookupProperty(object, map, instance_type, key, &return_true, |
428 { | 383 &return_false, &call_runtime); |
429 Label if_objectissimple(assembler); | |
430 assembler->Branch(assembler->Int32LessThanOrEqual( | |
431 instance_type, | |
432 assembler->Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)), | |
433 &call_runtime, &if_objectissimple); | |
434 assembler->Bind(&if_objectissimple); | |
435 } | |
436 | |
437 // TODO(verwaest): Perform a dictonary lookup on slow-mode receivers. | |
438 Node* bit_field3 = assembler->LoadMapBitField3(map); | |
439 Node* bit = assembler->BitFieldDecode<Map::DictionaryMap>(bit_field3); | |
440 Label if_isfastmap(assembler); | |
441 assembler->Branch(assembler->Word32Equal(bit, assembler->Int32Constant(0)), | |
442 &if_isfastmap, &call_runtime); | |
443 assembler->Bind(&if_isfastmap); | |
444 Node* nof = | |
445 assembler->BitFieldDecode<Map::NumberOfOwnDescriptorsBits>(bit_field3); | |
446 // Bail out to the runtime for large numbers of own descriptors. The stub only | |
447 // does linear search, which becomes too expensive in that case. | |
448 { | |
449 static const int32_t kMaxLinear = 256; | |
450 Label above_max(assembler), below_max(assembler); | |
451 assembler->Branch(assembler->Int32LessThanOrEqual( | |
452 nof, assembler->Int32Constant(kMaxLinear)), | |
453 &below_max, &call_runtime); | |
454 assembler->Bind(&below_max); | |
455 } | |
456 Node* descriptors = assembler->LoadMapDescriptors(map); | |
457 | |
458 Variable var_descriptor(assembler, MachineRepresentation::kWord32); | |
459 Label loop(assembler, &var_descriptor); | |
460 var_descriptor.Bind(assembler->Int32Constant(0)); | |
461 assembler->Goto(&loop); | |
462 assembler->Bind(&loop); | |
463 { | |
464 Node* index = var_descriptor.value(); | |
465 Node* offset = assembler->Int32Constant(DescriptorArray::ToKeyIndex(0)); | |
466 Node* factor = assembler->Int32Constant(DescriptorArray::kDescriptorSize); | |
467 Label if_notdone(assembler); | |
468 assembler->Branch(assembler->Word32Equal(index, nof), &return_false, | |
469 &if_notdone); | |
470 assembler->Bind(&if_notdone); | |
471 { | |
472 Node* array_index = | |
473 assembler->Int32Add(offset, assembler->Int32Mul(index, factor)); | |
474 Node* current = | |
475 assembler->LoadFixedArrayElementInt32Index(descriptors, array_index); | |
476 Label if_unequal(assembler); | |
477 assembler->Branch(assembler->WordEqual(current, key), &return_true, | |
478 &if_unequal); | |
479 assembler->Bind(&if_unequal); | |
480 | |
481 var_descriptor.Bind( | |
482 assembler->Int32Add(index, assembler->Int32Constant(1))); | |
483 assembler->Goto(&loop); | |
484 } | |
485 } | |
486 | 384 |
487 assembler->Bind(&keyisindex); | 385 assembler->Bind(&keyisindex); |
488 { | 386 assembler->TryLookupElement(object, map, instance_type, var_index.value(), |
489 Label if_objectissimple(assembler); | 387 &return_true, &return_false, &call_runtime); |
490 assembler->Branch(assembler->Int32LessThanOrEqual( | |
491 instance_type, assembler->Int32Constant( | |
492 LAST_CUSTOM_ELEMENTS_RECEIVER)), | |
493 &call_runtime, &if_objectissimple); | |
494 assembler->Bind(&if_objectissimple); | |
495 } | |
496 | |
497 Node* index = var_index.value(); | |
498 Node* bit_field2 = assembler->LoadMapBitField2(map); | |
499 Node* elements_kind = | |
500 assembler->BitFieldDecode<Map::ElementsKindBits>(bit_field2); | |
501 | |
502 // TODO(verwaest): Support other elements kinds as well. | |
503 Label if_isobjectorsmi(assembler); | |
504 assembler->Branch( | |
505 assembler->Int32LessThanOrEqual( | |
506 elements_kind, assembler->Int32Constant(FAST_HOLEY_ELEMENTS)), | |
507 &if_isobjectorsmi, &call_runtime); | |
508 assembler->Bind(&if_isobjectorsmi); | |
509 { | |
510 Node* elements = assembler->LoadElements(object); | |
511 Node* length = assembler->LoadFixedArrayBaseLength(elements); | |
512 | |
513 Label if_iskeyinrange(assembler); | |
514 assembler->Branch( | |
515 assembler->Int32LessThan(index, assembler->SmiToWord32(length)), | |
516 &if_iskeyinrange, &return_false); | |
517 | |
518 assembler->Bind(&if_iskeyinrange); | |
519 Node* element = assembler->LoadFixedArrayElementInt32Index(elements, index); | |
520 Node* the_hole = assembler->LoadRoot(Heap::kTheHoleValueRootIndex); | |
521 assembler->Branch(assembler->WordEqual(element, the_hole), &return_false, | |
522 &return_true); | |
523 } | |
524 | 388 |
525 assembler->Bind(&return_true); | 389 assembler->Bind(&return_true); |
526 assembler->Return(assembler->BooleanConstant(true)); | 390 assembler->Return(assembler->BooleanConstant(true)); |
527 | 391 |
528 assembler->Bind(&return_false); | 392 assembler->Bind(&return_false); |
529 assembler->Return(assembler->BooleanConstant(false)); | 393 assembler->Return(assembler->BooleanConstant(false)); |
530 | 394 |
531 assembler->Bind(&call_runtime); | 395 assembler->Bind(&call_runtime); |
532 assembler->Return(assembler->CallRuntime(Runtime::kObjectHasOwnProperty, | 396 assembler->Return(assembler->CallRuntime(Runtime::kObjectHasOwnProperty, |
533 context, object, key)); | 397 context, object, key)); |
(...skipping 4861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5395 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) | 5259 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) |
5396 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 5260 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
5397 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 5261 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
5398 #undef DEFINE_BUILTIN_ACCESSOR_C | 5262 #undef DEFINE_BUILTIN_ACCESSOR_C |
5399 #undef DEFINE_BUILTIN_ACCESSOR_A | 5263 #undef DEFINE_BUILTIN_ACCESSOR_A |
5400 #undef DEFINE_BUILTIN_ACCESSOR_T | 5264 #undef DEFINE_BUILTIN_ACCESSOR_T |
5401 #undef DEFINE_BUILTIN_ACCESSOR_H | 5265 #undef DEFINE_BUILTIN_ACCESSOR_H |
5402 | 5266 |
5403 } // namespace internal | 5267 } // namespace internal |
5404 } // namespace v8 | 5268 } // namespace v8 |
OLD | NEW |