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

Side by Side Diff: src/runtime.cc

Issue 148503002: A64: Synchronize with r15545. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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/runtime.h ('k') | src/runtime.js » ('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 20 matching lines...) Expand all
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #include "accessors.h" 33 #include "accessors.h"
34 #include "api.h" 34 #include "api.h"
35 #include "arguments.h" 35 #include "arguments.h"
36 #include "bootstrapper.h" 36 #include "bootstrapper.h"
37 #include "codegen.h" 37 #include "codegen.h"
38 #include "compilation-cache.h" 38 #include "compilation-cache.h"
39 #include "compiler.h" 39 #include "compiler.h"
40 #include "cpu.h" 40 #include "cpu.h"
41 #include "cpu-profiler.h"
41 #include "dateparser-inl.h" 42 #include "dateparser-inl.h"
42 #include "debug.h" 43 #include "debug.h"
43 #include "deoptimizer.h" 44 #include "deoptimizer.h"
44 #include "date.h" 45 #include "date.h"
45 #include "execution.h" 46 #include "execution.h"
46 #include "full-codegen.h" 47 #include "full-codegen.h"
47 #include "global-handles.h" 48 #include "global-handles.h"
48 #include "isolate-inl.h" 49 #include "isolate-inl.h"
49 #include "jsregexp.h" 50 #include "jsregexp.h"
50 #include "jsregexp-inl.h" 51 #include "jsregexp-inl.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 460 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
460 461
461 // Check if boilerplate exists. If not, create it first. 462 // Check if boilerplate exists. If not, create it first.
462 Handle<Object> boilerplate(literals->get(literals_index), isolate); 463 Handle<Object> boilerplate(literals->get(literals_index), isolate);
463 if (*boilerplate == isolate->heap()->undefined_value()) { 464 if (*boilerplate == isolate->heap()->undefined_value()) {
464 boilerplate = CreateObjectLiteralBoilerplate(isolate, 465 boilerplate = CreateObjectLiteralBoilerplate(isolate,
465 literals, 466 literals,
466 constant_properties, 467 constant_properties,
467 should_have_fast_elements, 468 should_have_fast_elements,
468 has_function_literal); 469 has_function_literal);
469 if (boilerplate.is_null()) return Failure::Exception(); 470 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate);
470 // Update the functions literal and return the boilerplate. 471 // Update the functions literal and return the boilerplate.
471 literals->set(literals_index, *boilerplate); 472 literals->set(literals_index, *boilerplate);
472 } 473 }
473 return JSObject::cast(*boilerplate)->DeepCopy(isolate); 474 return JSObject::cast(*boilerplate)->DeepCopy(isolate);
474 } 475 }
475 476
476 477
477 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { 478 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
478 HandleScope scope(isolate); 479 HandleScope scope(isolate);
479 ASSERT(args.length() == 4); 480 ASSERT(args.length() == 4);
480 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 481 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
481 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 482 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
482 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); 483 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
483 CONVERT_SMI_ARG_CHECKED(flags, 3); 484 CONVERT_SMI_ARG_CHECKED(flags, 3);
484 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 485 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
485 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 486 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
486 487
487 // Check if boilerplate exists. If not, create it first. 488 // Check if boilerplate exists. If not, create it first.
488 Handle<Object> boilerplate(literals->get(literals_index), isolate); 489 Handle<Object> boilerplate(literals->get(literals_index), isolate);
489 if (*boilerplate == isolate->heap()->undefined_value()) { 490 if (*boilerplate == isolate->heap()->undefined_value()) {
490 boilerplate = CreateObjectLiteralBoilerplate(isolate, 491 boilerplate = CreateObjectLiteralBoilerplate(isolate,
491 literals, 492 literals,
492 constant_properties, 493 constant_properties,
493 should_have_fast_elements, 494 should_have_fast_elements,
494 has_function_literal); 495 has_function_literal);
495 if (boilerplate.is_null()) return Failure::Exception(); 496 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate);
496 // Update the functions literal and return the boilerplate. 497 // Update the functions literal and return the boilerplate.
497 literals->set(literals_index, *boilerplate); 498 literals->set(literals_index, *boilerplate);
498 } 499 }
499 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); 500 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
500 } 501 }
501 502
502 503
504 static Handle<AllocationSite> GetLiteralAllocationSite(
505 Isolate* isolate,
506 Handle<FixedArray> literals,
507 int literals_index,
508 Handle<FixedArray> elements) {
509 // Check if boilerplate exists. If not, create it first.
510 Handle<Object> literal_site(literals->get(literals_index), isolate);
511 Handle<AllocationSite> site;
512 if (*literal_site == isolate->heap()->undefined_value()) {
513 ASSERT(*elements != isolate->heap()->empty_fixed_array());
514 Handle<Object> boilerplate =
515 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements);
516 if (boilerplate.is_null()) return site;
517 site = isolate->factory()->NewAllocationSite();
518 site->set_payload(*boilerplate);
519 literals->set(literals_index, *site);
520 } else {
521 site = Handle<AllocationSite>::cast(literal_site);
522 }
523
524 return site;
525 }
526
527
503 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { 528 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
504 HandleScope scope(isolate); 529 HandleScope scope(isolate);
505 ASSERT(args.length() == 3); 530 ASSERT(args.length() == 3);
506 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 531 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
507 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 532 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
508 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 533 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
509 534
510 // Check if boilerplate exists. If not, create it first. 535 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
511 Handle<Object> boilerplate(literals->get(literals_index), isolate); 536 literals_index, elements);
512 if (*boilerplate == isolate->heap()->undefined_value()) { 537 RETURN_IF_EMPTY_HANDLE(isolate, site);
513 ASSERT(*elements != isolate->heap()->empty_fixed_array()); 538
514 boilerplate = 539 JSObject* boilerplate = JSObject::cast(site->payload());
515 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); 540 return boilerplate->DeepCopy(isolate);
516 if (boilerplate.is_null()) return Failure::Exception();
517 // Update the functions literal and return the boilerplate.
518 literals->set(literals_index, *boilerplate);
519 }
520 return JSObject::cast(*boilerplate)->DeepCopy(isolate);
521 } 541 }
522 542
523 543
524 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { 544 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
525 HandleScope scope(isolate); 545 HandleScope scope(isolate);
526 ASSERT(args.length() == 3); 546 ASSERT(args.length() == 3);
527 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 547 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
528 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 548 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
529 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 549 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
530 550
531 // Check if boilerplate exists. If not, create it first. 551 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
532 Handle<Object> boilerplate(literals->get(literals_index), isolate); 552 literals_index, elements);
533 if (*boilerplate == isolate->heap()->undefined_value()) { 553 RETURN_IF_EMPTY_HANDLE(isolate, site);
534 ASSERT(*elements != isolate->heap()->empty_fixed_array()); 554
535 boilerplate = 555 JSObject* boilerplate = JSObject::cast(site->payload());
536 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); 556 if (boilerplate->elements()->map() ==
537 if (boilerplate.is_null()) return Failure::Exception();
538 // Update the functions literal and return the boilerplate.
539 literals->set(literals_index, *boilerplate);
540 }
541 if (JSObject::cast(*boilerplate)->elements()->map() ==
542 isolate->heap()->fixed_cow_array_map()) { 557 isolate->heap()->fixed_cow_array_map()) {
543 isolate->counters()->cow_arrays_created_runtime()->Increment(); 558 isolate->counters()->cow_arrays_created_runtime()->Increment();
544 } 559 }
545 560
546 JSObject* boilerplate_object = JSObject::cast(*boilerplate); 561 AllocationSiteMode mode = AllocationSite::GetMode(
547 AllocationSiteMode mode = AllocationSiteInfo::GetMode( 562 boilerplate->GetElementsKind());
548 boilerplate_object->GetElementsKind());
549 if (mode == TRACK_ALLOCATION_SITE) { 563 if (mode == TRACK_ALLOCATION_SITE) {
550 return isolate->heap()->CopyJSObjectWithAllocationSite(boilerplate_object); 564 return isolate->heap()->CopyJSObjectWithAllocationSite(
565 boilerplate, *site);
551 } 566 }
552 567
553 return isolate->heap()->CopyJSObject(boilerplate_object); 568 return isolate->heap()->CopyJSObject(boilerplate);
554 } 569 }
555 570
556 571
557 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { 572 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) {
558 HandleScope scope(isolate); 573 HandleScope scope(isolate);
559 ASSERT(args.length() == 1); 574 ASSERT(args.length() == 1);
560 Handle<Object> name(args[0], isolate); 575 Handle<Object> name(args[0], isolate);
561 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); 576 RUNTIME_ASSERT(name->IsString() || name->IsUndefined());
562 Symbol* symbol; 577 Symbol* symbol;
563 MaybeObject* maybe = isolate->heap()->AllocateSymbol(); 578 MaybeObject* maybe = isolate->heap()->AllocateSymbol();
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 803
789 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { 804 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) {
790 HandleScope scope(isolate); 805 HandleScope scope(isolate);
791 ASSERT(args.length() == 5); 806 ASSERT(args.length() == 5);
792 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); 807 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0);
793 CONVERT_SMI_ARG_CHECKED(arrayId, 1); 808 CONVERT_SMI_ARG_CHECKED(arrayId, 1);
794 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 2); 809 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 2);
795 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3); 810 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset_object, 3);
796 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4); 811 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length_object, 4);
797 812
813 ASSERT(holder->GetInternalFieldCount() ==
814 v8::ArrayBufferView::kInternalFieldCount);
815 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
816 holder->SetInternalField(i, Smi::FromInt(0));
817 }
818
798 ExternalArrayType arrayType; 819 ExternalArrayType arrayType;
799 size_t elementSize; 820 size_t elementSize;
800 switch (arrayId) { 821 switch (arrayId) {
801 case ARRAY_ID_UINT8: 822 case ARRAY_ID_UINT8:
802 arrayType = kExternalUnsignedByteArray; 823 arrayType = kExternalUnsignedByteArray;
803 elementSize = 1; 824 elementSize = 1;
804 break; 825 break;
805 case ARRAY_ID_INT8: 826 case ARRAY_ID_INT8:
806 arrayType = kExternalByteArray; 827 arrayType = kExternalByteArray;
807 elementSize = 1; 828 elementSize = 1;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1025
1005 1026
1006 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { 1027 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) {
1007 HandleScope scope(isolate); 1028 HandleScope scope(isolate);
1008 ASSERT(args.length() == 4); 1029 ASSERT(args.length() == 4);
1009 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); 1030 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0);
1010 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); 1031 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1);
1011 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); 1032 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2);
1012 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); 1033 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3);
1013 1034
1035 ASSERT(holder->GetInternalFieldCount() ==
1036 v8::ArrayBufferView::kInternalFieldCount);
1037 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
1038 holder->SetInternalField(i, Smi::FromInt(0));
1039 }
1040
1014 holder->set_buffer(*buffer); 1041 holder->set_buffer(*buffer);
1015 ASSERT(byte_offset->IsNumber()); 1042 ASSERT(byte_offset->IsNumber());
1016 ASSERT( 1043 ASSERT(
1017 NumberToSize(isolate, buffer->byte_length()) >= 1044 NumberToSize(isolate, buffer->byte_length()) >=
1018 NumberToSize(isolate, *byte_offset) 1045 NumberToSize(isolate, *byte_offset)
1019 + NumberToSize(isolate, *byte_length)); 1046 + NumberToSize(isolate, *byte_length));
1020 holder->set_byte_offset(*byte_offset); 1047 holder->set_byte_offset(*byte_offset);
1021 ASSERT(byte_length->IsNumber()); 1048 ASSERT(byte_length->IsNumber());
1022 holder->set_byte_length(*byte_length); 1049 holder->set_byte_length(*byte_length);
1023 1050
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 Object* current = receiver->GetPrototype(isolate); 1470 Object* current = receiver->GetPrototype(isolate);
1444 while (current->IsJSObject() && 1471 while (current->IsJSObject() &&
1445 JSObject::cast(current)->map()->is_hidden_prototype()) { 1472 JSObject::cast(current)->map()->is_hidden_prototype()) {
1446 current = current->GetPrototype(isolate); 1473 current = current->GetPrototype(isolate);
1447 } 1474 }
1448 return current; 1475 return current;
1449 } 1476 }
1450 1477
1451 1478
1452 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) { 1479 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) {
1453 SealHandleScope shs(isolate); 1480 HandleScope scope(isolate);
1454 ASSERT(args.length() == 2); 1481 ASSERT(args.length() == 2);
1455 CONVERT_ARG_CHECKED(JSObject, obj, 0); 1482 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
1456 CONVERT_ARG_CHECKED(Object, prototype, 1); 1483 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
1457 if (FLAG_harmony_observation && obj->map()->is_observed()) { 1484 if (FLAG_harmony_observation && obj->map()->is_observed()) {
1458 HandleScope scope(isolate);
1459 Handle<JSObject> receiver(obj);
1460 Handle<Object> value(prototype, isolate);
1461 Handle<Object> old_value( 1485 Handle<Object> old_value(
1462 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); 1486 GetPrototypeSkipHiddenPrototypes(isolate, *obj), isolate);
1463 1487
1464 MaybeObject* result = receiver->SetPrototype(*value, true); 1488 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true);
1465 Handle<Object> hresult; 1489 RETURN_IF_EMPTY_HANDLE(isolate, result);
1466 if (!result->ToHandle(&hresult, isolate)) return result;
1467 1490
1468 Handle<Object> new_value( 1491 Handle<Object> new_value(
1469 GetPrototypeSkipHiddenPrototypes(isolate, *receiver), isolate); 1492 GetPrototypeSkipHiddenPrototypes(isolate, *obj), isolate);
1470 if (!new_value->SameValue(*old_value)) { 1493 if (!new_value->SameValue(*old_value)) {
1471 JSObject::EnqueueChangeRecord(receiver, "prototype", 1494 JSObject::EnqueueChangeRecord(obj, "prototype",
1472 isolate->factory()->proto_string(), 1495 isolate->factory()->proto_string(),
1473 old_value); 1496 old_value);
1474 } 1497 }
1475 return *hresult; 1498 return *result;
1476 } 1499 }
1477 return obj->SetPrototype(prototype, true); 1500 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true);
1501 RETURN_IF_EMPTY_HANDLE(isolate, result);
1502 return *result;
1478 } 1503 }
1479 1504
1480 1505
1481 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { 1506 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) {
1482 SealHandleScope shs(isolate); 1507 SealHandleScope shs(isolate);
1483 ASSERT(args.length() == 2); 1508 ASSERT(args.length() == 2);
1484 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). 1509 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
1485 Object* O = args[0]; 1510 Object* O = args[0];
1486 Object* V = args[1]; 1511 Object* V = args[1];
1487 while (true) { 1512 while (true) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 1654
1630 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); 1655 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
1631 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); 1656 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0));
1632 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); 1657 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0));
1633 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); 1658 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL));
1634 1659
1635 if (raw_accessors == NULL) { 1660 if (raw_accessors == NULL) {
1636 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); 1661 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0));
1637 // GetProperty does access check. 1662 // GetProperty does access check.
1638 Handle<Object> value = GetProperty(isolate, obj, name); 1663 Handle<Object> value = GetProperty(isolate, obj, name);
1639 if (value.is_null()) return Failure::Exception(); 1664 RETURN_IF_EMPTY_HANDLE(isolate, value);
1640 elms->set(VALUE_INDEX, *value); 1665 elms->set(VALUE_INDEX, *value);
1641 } else { 1666 } else {
1642 // Access checks are performed for both accessors separately. 1667 // Access checks are performed for both accessors separately.
1643 // When they fail, the respective field is not set in the descriptor. 1668 // When they fail, the respective field is not set in the descriptor.
1644 Object* getter = accessors->GetComponent(ACCESSOR_GETTER); 1669 Object* getter = accessors->GetComponent(ACCESSOR_GETTER);
1645 Object* setter = accessors->GetComponent(ACCESSOR_SETTER); 1670 Object* setter = accessors->GetComponent(ACCESSOR_SETTER);
1646 if (!getter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_GET)) { 1671 if (!getter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_GET)) {
1647 elms->set(GETTER_INDEX, getter); 1672 elms->set(GETTER_INDEX, getter);
1648 } 1673 }
1649 if (!setter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_SET)) { 1674 if (!setter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_SET)) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 1719
1695 1720
1696 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { 1721 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) {
1697 HandleScope scope(isolate); 1722 HandleScope scope(isolate);
1698 ASSERT(args.length() == 3); 1723 ASSERT(args.length() == 3);
1699 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); 1724 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0);
1700 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); 1725 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
1701 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); 1726 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2);
1702 Handle<Object> result = 1727 Handle<Object> result =
1703 RegExpImpl::Compile(re, pattern, flags); 1728 RegExpImpl::Compile(re, pattern, flags);
1704 if (result.is_null()) return Failure::Exception(); 1729 RETURN_IF_EMPTY_HANDLE(isolate, result);
1705 return *result; 1730 return *result;
1706 } 1731 }
1707 1732
1708 1733
1709 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { 1734 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) {
1710 HandleScope scope(isolate); 1735 HandleScope scope(isolate);
1711 ASSERT(args.length() == 1); 1736 ASSERT(args.length() == 1);
1712 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); 1737 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0);
1713 return *isolate->factory()->CreateApiFunction(data); 1738 return *isolate->factory()->CreateApiFunction(data);
1714 } 1739 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 // Strict mode handling not needed (const is disallowed in strict mode). 2128 // Strict mode handling not needed (const is disallowed in strict mode).
2104 if (lookup.IsField()) { 2129 if (lookup.IsField()) {
2105 FixedArray* properties = global->properties(); 2130 FixedArray* properties = global->properties();
2106 int index = lookup.GetFieldIndex().field_index(); 2131 int index = lookup.GetFieldIndex().field_index();
2107 if (properties->get(index)->IsTheHole() || !lookup.IsReadOnly()) { 2132 if (properties->get(index)->IsTheHole() || !lookup.IsReadOnly()) {
2108 properties->set(index, *value); 2133 properties->set(index, *value);
2109 } 2134 }
2110 } else if (lookup.IsNormal()) { 2135 } else if (lookup.IsNormal()) {
2111 if (global->GetNormalizedProperty(&lookup)->IsTheHole() || 2136 if (global->GetNormalizedProperty(&lookup)->IsTheHole() ||
2112 !lookup.IsReadOnly()) { 2137 !lookup.IsReadOnly()) {
2113 global->SetNormalizedProperty(&lookup, *value); 2138 HandleScope scope(isolate);
2139 JSObject::SetNormalizedProperty(Handle<JSObject>(global), &lookup, value);
2114 } 2140 }
2115 } else { 2141 } else {
2116 // Ignore re-initialization of constants that have already been 2142 // Ignore re-initialization of constants that have already been
2117 // assigned a function value. 2143 // assigned a function value.
2118 ASSERT(lookup.IsReadOnly() && lookup.IsConstantFunction()); 2144 ASSERT(lookup.IsReadOnly() && lookup.IsConstantFunction());
2119 } 2145 }
2120 2146
2121 // Use the set value as the result of the operation. 2147 // Use the set value as the result of the operation.
2122 return *value; 2148 return *value;
2123 } 2149 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 ASSERT(lookup.IsReadOnly()); // and it was declared as read-only 2218 ASSERT(lookup.IsReadOnly()); // and it was declared as read-only
2193 2219
2194 if (lookup.IsField()) { 2220 if (lookup.IsField()) {
2195 FixedArray* properties = object->properties(); 2221 FixedArray* properties = object->properties();
2196 int index = lookup.GetFieldIndex().field_index(); 2222 int index = lookup.GetFieldIndex().field_index();
2197 if (properties->get(index)->IsTheHole()) { 2223 if (properties->get(index)->IsTheHole()) {
2198 properties->set(index, *value); 2224 properties->set(index, *value);
2199 } 2225 }
2200 } else if (lookup.IsNormal()) { 2226 } else if (lookup.IsNormal()) {
2201 if (object->GetNormalizedProperty(&lookup)->IsTheHole()) { 2227 if (object->GetNormalizedProperty(&lookup)->IsTheHole()) {
2202 object->SetNormalizedProperty(&lookup, *value); 2228 JSObject::SetNormalizedProperty(object, &lookup, value);
2203 } 2229 }
2204 } else { 2230 } else {
2205 // We should not reach here. Any real, named property should be 2231 // We should not reach here. Any real, named property should be
2206 // either a field or a dictionary slot. 2232 // either a field or a dictionary slot.
2207 UNREACHABLE(); 2233 UNREACHABLE();
2208 } 2234 }
2209 } else { 2235 } else {
2210 // The property was found on some other object. Set it if it is not a 2236 // The property was found on some other object. Set it if it is not a
2211 // read-only property. 2237 // read-only property.
2212 if ((attributes & READ_ONLY) == 0) { 2238 if ((attributes & READ_ONLY) == 0) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 // length of a string, i.e. it is always a Smi. We check anyway for security. 2270 // length of a string, i.e. it is always a Smi. We check anyway for security.
2245 CONVERT_SMI_ARG_CHECKED(index, 2); 2271 CONVERT_SMI_ARG_CHECKED(index, 2);
2246 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); 2272 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
2247 RUNTIME_ASSERT(index >= 0); 2273 RUNTIME_ASSERT(index >= 0);
2248 RUNTIME_ASSERT(index <= subject->length()); 2274 RUNTIME_ASSERT(index <= subject->length());
2249 isolate->counters()->regexp_entry_runtime()->Increment(); 2275 isolate->counters()->regexp_entry_runtime()->Increment();
2250 Handle<Object> result = RegExpImpl::Exec(regexp, 2276 Handle<Object> result = RegExpImpl::Exec(regexp,
2251 subject, 2277 subject,
2252 index, 2278 index,
2253 last_match_info); 2279 last_match_info);
2254 if (result.is_null()) return Failure::Exception(); 2280 RETURN_IF_EMPTY_HANDLE(isolate, result);
2255 return *result; 2281 return *result;
2256 } 2282 }
2257 2283
2258 2284
2259 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { 2285 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) {
2260 SealHandleScope shs(isolate); 2286 SealHandleScope shs(isolate);
2261 ASSERT(args.length() == 3); 2287 ASSERT(args.length() == 3);
2262 CONVERT_SMI_ARG_CHECKED(elements_count, 0); 2288 CONVERT_SMI_ARG_CHECKED(elements_count, 0);
2263 if (elements_count < 0 || 2289 if (elements_count < 0 ||
2264 elements_count > FixedArray::kMaxLength || 2290 elements_count > FixedArray::kMaxLength ||
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
3593 template<typename ResultSeqString> 3619 template<typename ResultSeqString>
3594 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalAtomRegExpWithString( 3620 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalAtomRegExpWithString(
3595 Isolate* isolate, 3621 Isolate* isolate,
3596 Handle<String> subject, 3622 Handle<String> subject,
3597 Handle<JSRegExp> pattern_regexp, 3623 Handle<JSRegExp> pattern_regexp,
3598 Handle<String> replacement, 3624 Handle<String> replacement,
3599 Handle<JSArray> last_match_info) { 3625 Handle<JSArray> last_match_info) {
3600 ASSERT(subject->IsFlat()); 3626 ASSERT(subject->IsFlat());
3601 ASSERT(replacement->IsFlat()); 3627 ASSERT(replacement->IsFlat());
3602 3628
3603 Zone zone(isolate); 3629 ZoneScope zone_scope(isolate->runtime_zone());
3604 ZoneList<int> indices(8, &zone); 3630 ZoneList<int> indices(8, zone_scope.zone());
3605 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); 3631 ASSERT_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
3606 String* pattern = 3632 String* pattern =
3607 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex)); 3633 String::cast(pattern_regexp->DataAt(JSRegExp::kAtomPatternIndex));
3608 int subject_len = subject->length(); 3634 int subject_len = subject->length();
3609 int pattern_len = pattern->length(); 3635 int pattern_len = pattern->length();
3610 int replacement_len = replacement->length(); 3636 int replacement_len = replacement->length();
3611 3637
3612 FindStringIndicesDispatch( 3638 FindStringIndicesDispatch(
3613 isolate, *subject, pattern, &indices, 0xffffffff, &zone); 3639 isolate, *subject, pattern, &indices, 0xffffffff, zone_scope.zone());
3614 3640
3615 int matches = indices.length(); 3641 int matches = indices.length();
3616 if (matches == 0) return *subject; 3642 if (matches == 0) return *subject;
3617 3643
3618 // Detect integer overflow. 3644 // Detect integer overflow.
3619 int64_t result_len_64 = 3645 int64_t result_len_64 =
3620 (static_cast<int64_t>(replacement_len) - 3646 (static_cast<int64_t>(replacement_len) -
3621 static_cast<int64_t>(pattern_len)) * 3647 static_cast<int64_t>(pattern_len)) *
3622 static_cast<int64_t>(matches) + 3648 static_cast<int64_t>(matches) +
3623 static_cast<int64_t>(subject_len); 3649 static_cast<int64_t>(subject_len);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 Handle<JSRegExp> regexp, 3705 Handle<JSRegExp> regexp,
3680 Handle<String> replacement, 3706 Handle<String> replacement,
3681 Handle<JSArray> last_match_info) { 3707 Handle<JSArray> last_match_info) {
3682 ASSERT(subject->IsFlat()); 3708 ASSERT(subject->IsFlat());
3683 ASSERT(replacement->IsFlat()); 3709 ASSERT(replacement->IsFlat());
3684 3710
3685 int capture_count = regexp->CaptureCount(); 3711 int capture_count = regexp->CaptureCount();
3686 int subject_length = subject->length(); 3712 int subject_length = subject->length();
3687 3713
3688 // CompiledReplacement uses zone allocation. 3714 // CompiledReplacement uses zone allocation.
3689 Zone zone(isolate); 3715 ZoneScope zone_scope(isolate->runtime_zone());
3690 CompiledReplacement compiled_replacement(&zone); 3716 CompiledReplacement compiled_replacement(zone_scope.zone());
3691 bool simple_replace = compiled_replacement.Compile(replacement, 3717 bool simple_replace = compiled_replacement.Compile(replacement,
3692 capture_count, 3718 capture_count,
3693 subject_length); 3719 subject_length);
3694 3720
3695 // Shortcut for simple non-regexp global replacements 3721 // Shortcut for simple non-regexp global replacements
3696 if (regexp->TypeTag() == JSRegExp::ATOM && simple_replace) { 3722 if (regexp->TypeTag() == JSRegExp::ATOM && simple_replace) {
3697 if (subject->HasOnlyOneByteChars() && 3723 if (subject->HasOnlyOneByteChars() &&
3698 replacement->HasOnlyOneByteChars()) { 3724 replacement->HasOnlyOneByteChars()) {
3699 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( 3725 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>(
3700 isolate, subject, regexp, replacement, last_match_info); 3726 isolate, subject, regexp, replacement, last_match_info);
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
4062 } 4088 }
4063 j++; 4089 j++;
4064 } 4090 }
4065 if (j == pattern_length) { 4091 if (j == pattern_length) {
4066 return i; 4092 return i;
4067 } 4093 }
4068 } 4094 }
4069 return -1; 4095 return -1;
4070 } 4096 }
4071 4097
4098
4072 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { 4099 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) {
4073 HandleScope scope(isolate); 4100 HandleScope scope(isolate);
4074 ASSERT(args.length() == 3); 4101 ASSERT(args.length() == 3);
4075 4102
4076 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); 4103 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0);
4077 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); 4104 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1);
4078 4105
4079 Object* index = args[2]; 4106 Object* index = args[2];
4080 uint32_t start_index; 4107 uint32_t start_index;
4081 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); 4108 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
4213 4240
4214 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 4241 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
4215 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 4242 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
4216 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); 4243 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
4217 4244
4218 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); 4245 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate);
4219 if (global_cache.HasException()) return Failure::Exception(); 4246 if (global_cache.HasException()) return Failure::Exception();
4220 4247
4221 int capture_count = regexp->CaptureCount(); 4248 int capture_count = regexp->CaptureCount();
4222 4249
4223 Zone zone(isolate); 4250 ZoneScope zone_scope(isolate->runtime_zone());
4224 ZoneList<int> offsets(8, &zone); 4251 ZoneList<int> offsets(8, zone_scope.zone());
4225 4252
4226 while (true) { 4253 while (true) {
4227 int32_t* match = global_cache.FetchNext(); 4254 int32_t* match = global_cache.FetchNext();
4228 if (match == NULL) break; 4255 if (match == NULL) break;
4229 offsets.Add(match[0], &zone); // start 4256 offsets.Add(match[0], zone_scope.zone()); // start
4230 offsets.Add(match[1], &zone); // end 4257 offsets.Add(match[1], zone_scope.zone()); // end
4231 } 4258 }
4232 4259
4233 if (global_cache.HasException()) return Failure::Exception(); 4260 if (global_cache.HasException()) return Failure::Exception();
4234 4261
4235 if (offsets.length() == 0) { 4262 if (offsets.length() == 0) {
4236 // Not a single match. 4263 // Not a single match.
4237 return isolate->heap()->null_value(); 4264 return isolate->heap()->null_value();
4238 } 4265 }
4239 4266
4240 RegExpImpl::SetLastMatchInfo(regexp_info, 4267 RegExpImpl::SetLastMatchInfo(regexp_info,
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
4783 CONVERT_SMI_ARG_CHECKED(unchecked, 4); 4810 CONVERT_SMI_ARG_CHECKED(unchecked, 4);
4784 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4811 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4785 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); 4812 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4786 4813
4787 bool fast = obj->HasFastProperties(); 4814 bool fast = obj->HasFastProperties();
4788 JSObject::DefineAccessor(obj, name, getter, setter, attr); 4815 JSObject::DefineAccessor(obj, name, getter, setter, attr);
4789 if (fast) JSObject::TransformToFastProperties(obj, 0); 4816 if (fast) JSObject::TransformToFastProperties(obj, 0);
4790 return isolate->heap()->undefined_value(); 4817 return isolate->heap()->undefined_value();
4791 } 4818 }
4792 4819
4820
4793 // Implements part of 8.12.9 DefineOwnProperty. 4821 // Implements part of 8.12.9 DefineOwnProperty.
4794 // There are 3 cases that lead here: 4822 // There are 3 cases that lead here:
4795 // Step 4a - define a new data property. 4823 // Step 4a - define a new data property.
4796 // Steps 9b & 12 - replace an existing accessor property with a data property. 4824 // Steps 9b & 12 - replace an existing accessor property with a data property.
4797 // Step 12 - update an existing data property with a data or generic 4825 // Step 12 - update an existing data property with a data or generic
4798 // descriptor. 4826 // descriptor.
4799 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { 4827 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
4800 HandleScope scope(isolate); 4828 HandleScope scope(isolate);
4801 ASSERT(args.length() == 4); 4829 ASSERT(args.length() == 4);
4802 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); 4830 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
5182 5210
5183 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { 5211 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
5184 HandleScope scope(isolate); 5212 HandleScope scope(isolate);
5185 RUNTIME_ASSERT(args.length() == 5); 5213 RUNTIME_ASSERT(args.length() == 5);
5186 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5214 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5187 CONVERT_SMI_ARG_CHECKED(store_index, 1); 5215 CONVERT_SMI_ARG_CHECKED(store_index, 1);
5188 Handle<Object> value = args.at<Object>(2); 5216 Handle<Object> value = args.at<Object>(2);
5189 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); 5217 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3);
5190 CONVERT_SMI_ARG_CHECKED(literal_index, 4); 5218 CONVERT_SMI_ARG_CHECKED(literal_index, 4);
5191 5219
5192 Object* raw_boilerplate_object = literals->get(literal_index); 5220 Object* raw_literal_cell = literals->get(literal_index);
5193 Handle<JSArray> boilerplate_object(JSArray::cast(raw_boilerplate_object)); 5221 JSArray* boilerplate = NULL;
5222 if (raw_literal_cell->IsAllocationSite()) {
5223 AllocationSite* site = AllocationSite::cast(raw_literal_cell);
5224 boilerplate = JSArray::cast(site->payload());
5225 } else {
5226 boilerplate = JSArray::cast(raw_literal_cell);
5227 }
5228 Handle<JSArray> boilerplate_object(boilerplate);
5194 ElementsKind elements_kind = object->GetElementsKind(); 5229 ElementsKind elements_kind = object->GetElementsKind();
5195 ASSERT(IsFastElementsKind(elements_kind)); 5230 ASSERT(IsFastElementsKind(elements_kind));
5196 // Smis should never trigger transitions. 5231 // Smis should never trigger transitions.
5197 ASSERT(!value->IsSmi()); 5232 ASSERT(!value->IsSmi());
5198 5233
5199 if (value->IsNumber()) { 5234 if (value->IsNumber()) {
5200 ASSERT(IsFastSmiElementsKind(elements_kind)); 5235 ASSERT(IsFastSmiElementsKind(elements_kind));
5201 ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind) 5236 ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind)
5202 ? FAST_HOLEY_DOUBLE_ELEMENTS 5237 ? FAST_HOLEY_DOUBLE_ELEMENTS
5203 : FAST_DOUBLE_ELEMENTS; 5238 : FAST_DOUBLE_ELEMENTS;
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
6305 } 6340 }
6306 6341
6307 // The limit can be very large (0xffffffffu), but since the pattern 6342 // The limit can be very large (0xffffffffu), but since the pattern
6308 // isn't empty, we can never create more parts than ~half the length 6343 // isn't empty, we can never create more parts than ~half the length
6309 // of the subject. 6344 // of the subject.
6310 6345
6311 if (!subject->IsFlat()) FlattenString(subject); 6346 if (!subject->IsFlat()) FlattenString(subject);
6312 6347
6313 static const int kMaxInitialListCapacity = 16; 6348 static const int kMaxInitialListCapacity = 16;
6314 6349
6315 Zone zone(isolate); 6350 ZoneScope zone_scope(isolate->runtime_zone());
6316 6351
6317 // Find (up to limit) indices of separator and end-of-string in subject 6352 // Find (up to limit) indices of separator and end-of-string in subject
6318 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); 6353 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
6319 ZoneList<int> indices(initial_capacity, &zone); 6354 ZoneList<int> indices(initial_capacity, zone_scope.zone());
6320 if (!pattern->IsFlat()) FlattenString(pattern); 6355 if (!pattern->IsFlat()) FlattenString(pattern);
6321 6356
6322 FindStringIndicesDispatch(isolate, *subject, *pattern, 6357 FindStringIndicesDispatch(isolate, *subject, *pattern,
6323 &indices, limit, &zone); 6358 &indices, limit, zone_scope.zone());
6324 6359
6325 if (static_cast<uint32_t>(indices.length()) < limit) { 6360 if (static_cast<uint32_t>(indices.length()) < limit) {
6326 indices.Add(subject_length, &zone); 6361 indices.Add(subject_length, zone_scope.zone());
6327 } 6362 }
6328 6363
6329 // The list indices now contains the end of each part to create. 6364 // The list indices now contains the end of each part to create.
6330 6365
6331 // Create JSArray of substrings separated by separator. 6366 // Create JSArray of substrings separated by separator.
6332 int part_count = indices.length(); 6367 int part_count = indices.length();
6333 6368
6334 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count); 6369 Handle<JSArray> result = isolate->factory()->NewJSArray(part_count);
6335 MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements(); 6370 MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements();
6336 if (maybe_result->IsFailure()) return maybe_result; 6371 if (maybe_result->IsFailure()) return maybe_result;
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
7457 7492
7458 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { 7493 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) {
7459 SealHandleScope shs(isolate); 7494 SealHandleScope shs(isolate);
7460 ASSERT(args.length() == 1); 7495 ASSERT(args.length() == 1);
7461 isolate->counters()->math_log()->Increment(); 7496 isolate->counters()->math_log()->Increment();
7462 7497
7463 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7498 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7464 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); 7499 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x);
7465 } 7500 }
7466 7501
7502
7467 // Slow version of Math.pow. We check for fast paths for special cases. 7503 // Slow version of Math.pow. We check for fast paths for special cases.
7468 // Used if SSE2/VFP3 is not available. 7504 // Used if SSE2/VFP3 is not available.
7469 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { 7505 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) {
7470 SealHandleScope shs(isolate); 7506 SealHandleScope shs(isolate);
7471 ASSERT(args.length() == 2); 7507 ASSERT(args.length() == 2);
7472 isolate->counters()->math_pow()->Increment(); 7508 isolate->counters()->math_pow()->Increment();
7473 7509
7474 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7510 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7475 7511
7476 // If the second argument is a smi, it is much faster to call the 7512 // If the second argument is a smi, it is much faster to call the
7477 // custom powi() function than the generic pow(). 7513 // custom powi() function than the generic pow().
7478 if (args[1]->IsSmi()) { 7514 if (args[1]->IsSmi()) {
7479 int y = args.smi_at(1); 7515 int y = args.smi_at(1);
7480 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); 7516 return isolate->heap()->NumberFromDouble(power_double_int(x, y));
7481 } 7517 }
7482 7518
7483 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7519 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7484 double result = power_helper(x, y); 7520 double result = power_helper(x, y);
7485 if (std::isnan(result)) return isolate->heap()->nan_value(); 7521 if (std::isnan(result)) return isolate->heap()->nan_value();
7486 return isolate->heap()->AllocateHeapNumber(result); 7522 return isolate->heap()->AllocateHeapNumber(result);
7487 } 7523 }
7488 7524
7525
7489 // Fast version of Math.pow if we know that y is not an integer and y is not 7526 // Fast version of Math.pow if we know that y is not an integer and y is not
7490 // -0.5 or 0.5. Used as slow case from full codegen. 7527 // -0.5 or 0.5. Used as slow case from full codegen.
7491 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { 7528 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) {
7492 SealHandleScope shs(isolate); 7529 SealHandleScope shs(isolate);
7493 ASSERT(args.length() == 2); 7530 ASSERT(args.length() == 2);
7494 isolate->counters()->math_pow()->Increment(); 7531 isolate->counters()->math_pow()->Increment();
7495 7532
7496 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7533 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7497 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7534 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7498 if (y == 0) { 7535 if (y == 0) {
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
8307 8344
8308 return isolate->heap()->undefined_value(); 8345 return isolate->heap()->undefined_value();
8309 } 8346 }
8310 8347
8311 8348
8312 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompleteOptimization) { 8349 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompleteOptimization) {
8313 HandleScope scope(isolate); 8350 HandleScope scope(isolate);
8314 ASSERT(args.length() == 1); 8351 ASSERT(args.length() == 1);
8315 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8352 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8316 if (FLAG_parallel_recompilation && V8::UseCrankshaft()) { 8353 if (FLAG_parallel_recompilation && V8::UseCrankshaft()) {
8317 // While function is in optimization pipeline, it is marked with builtins. 8354 // While function is in optimization pipeline, it is marked accordingly.
8318 while (function->code()->kind() == Code::BUILTIN) { 8355 // Note that if the debugger is activated during parallel recompilation,
8356 // the function will be marked with the lazy-recompile builtin, which is
8357 // not related to parallel recompilation.
8358 while (function->IsMarkedForParallelRecompilation() ||
8359 function->IsInRecompileQueue() ||
8360 function->IsMarkedForInstallingRecompiledCode()) {
8319 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); 8361 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
8320 OS::Sleep(50); 8362 OS::Sleep(50);
8321 } 8363 }
8322 } 8364 }
8323 return isolate->heap()->undefined_value(); 8365 return isolate->heap()->undefined_value();
8324 } 8366 }
8325 8367
8326 8368
8327 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { 8369 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) {
8328 HandleScope scope(isolate); 8370 HandleScope scope(isolate);
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
8841 // (edx:eax on ia32, r1:r0 on ARM). 8883 // (edx:eax on ia32, r1:r0 on ARM).
8842 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. 8884 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax.
8843 // In Win64 calling convention, a struct of two pointers is returned in memory, 8885 // In Win64 calling convention, a struct of two pointers is returned in memory,
8844 // allocated by the caller, and passed as a pointer in a hidden first parameter. 8886 // allocated by the caller, and passed as a pointer in a hidden first parameter.
8845 #ifdef V8_HOST_ARCH_64_BIT 8887 #ifdef V8_HOST_ARCH_64_BIT
8846 struct ObjectPair { 8888 struct ObjectPair {
8847 MaybeObject* x; 8889 MaybeObject* x;
8848 MaybeObject* y; 8890 MaybeObject* y;
8849 }; 8891 };
8850 8892
8893
8851 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) { 8894 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
8852 ObjectPair result = {x, y}; 8895 ObjectPair result = {x, y};
8853 // Pointers x and y returned in rax and rdx, in AMD-x64-abi. 8896 // Pointers x and y returned in rax and rdx, in AMD-x64-abi.
8854 // In Win64 they are assigned to a hidden first argument. 8897 // In Win64 they are assigned to a hidden first argument.
8855 return result; 8898 return result;
8856 } 8899 }
8857 #else 8900 #else
8858 typedef uint64_t ObjectPair; 8901 typedef uint64_t ObjectPair;
8859 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) { 8902 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
8860 return reinterpret_cast<uint32_t>(x) | 8903 return reinterpret_cast<uint32_t>(x) |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
9366 context->ErrorMessageForCodeGenerationFromStrings(); 9409 context->ErrorMessageForCodeGenerationFromStrings();
9367 return isolate->Throw(*isolate->factory()->NewEvalError( 9410 return isolate->Throw(*isolate->factory()->NewEvalError(
9368 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9411 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9369 } 9412 }
9370 9413
9371 // Compile source string in the native context. 9414 // Compile source string in the native context.
9372 ParseRestriction restriction = function_literal_only 9415 ParseRestriction restriction = function_literal_only
9373 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; 9416 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION;
9374 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 9417 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
9375 source, context, true, CLASSIC_MODE, restriction, RelocInfo::kNoPosition); 9418 source, context, true, CLASSIC_MODE, restriction, RelocInfo::kNoPosition);
9376 if (shared.is_null()) return Failure::Exception(); 9419 RETURN_IF_EMPTY_HANDLE(isolate, shared);
9377 Handle<JSFunction> fun = 9420 Handle<JSFunction> fun =
9378 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, 9421 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
9379 context, 9422 context,
9380 NOT_TENURED); 9423 NOT_TENURED);
9381 return *fun; 9424 return *fun;
9382 } 9425 }
9383 9426
9384 9427
9385 static ObjectPair CompileGlobalEval(Isolate* isolate, 9428 static ObjectPair CompileGlobalEval(Isolate* isolate,
9386 Handle<String> source, 9429 Handle<String> source,
(...skipping 16 matching lines...) Expand all
9403 9446
9404 // Deal with a normal eval call with a string argument. Compile it 9447 // Deal with a normal eval call with a string argument. Compile it
9405 // and return the compiled function bound in the local context. 9448 // and return the compiled function bound in the local context.
9406 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 9449 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
9407 source, 9450 source,
9408 context, 9451 context,
9409 context->IsNativeContext(), 9452 context->IsNativeContext(),
9410 language_mode, 9453 language_mode,
9411 NO_PARSE_RESTRICTION, 9454 NO_PARSE_RESTRICTION,
9412 scope_position); 9455 scope_position);
9413 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); 9456 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, shared,
9457 MakePair(Failure::Exception(), NULL));
9414 Handle<JSFunction> compiled = 9458 Handle<JSFunction> compiled =
9415 isolate->factory()->NewFunctionFromSharedFunctionInfo( 9459 isolate->factory()->NewFunctionFromSharedFunctionInfo(
9416 shared, context, NOT_TENURED); 9460 shared, context, NOT_TENURED);
9417 return MakePair(*compiled, *receiver); 9461 return MakePair(*compiled, *receiver);
9418 } 9462 }
9419 9463
9420 9464
9421 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { 9465 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
9422 HandleScope scope(isolate); 9466 HandleScope scope(isolate);
9423 ASSERT(args.length() == 5); 9467 ASSERT(args.length() == 5);
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
10222 CONVERT_ARG_CHECKED(String, string, 0); 10266 CONVERT_ARG_CHECKED(String, string, 0);
10223 ConsStringIteratorOp op; 10267 ConsStringIteratorOp op;
10224 StringCharacterStream stream(string, &op); 10268 StringCharacterStream stream(string, &op);
10225 while (stream.HasMore()) { 10269 while (stream.HasMore()) {
10226 uint16_t character = stream.GetNext(); 10270 uint16_t character = stream.GetNext();
10227 PrintF("%c", character); 10271 PrintF("%c", character);
10228 } 10272 }
10229 return string; 10273 return string;
10230 } 10274 }
10231 10275
10276
10232 // Moves all own elements of an object, that are below a limit, to positions 10277 // Moves all own elements of an object, that are below a limit, to positions
10233 // starting at zero. All undefined values are placed after non-undefined values, 10278 // starting at zero. All undefined values are placed after non-undefined values,
10234 // and are followed by non-existing element. Does not change the length 10279 // and are followed by non-existing element. Does not change the length
10235 // property. 10280 // property.
10236 // Returns the number of non-undefined elements collected. 10281 // Returns the number of non-undefined elements collected.
10237 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { 10282 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) {
10238 SealHandleScope shs(isolate); 10283 SealHandleScope shs(isolate);
10239 ASSERT(args.length() == 2); 10284 ASSERT(args.length() == 2);
10240 CONVERT_ARG_CHECKED(JSObject, object, 0); 10285 CONVERT_ARG_CHECKED(JSObject, object, 0);
10241 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 10286 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
11839 11884
11840 // Fill in scope details. 11885 // Fill in scope details.
11841 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it->Type())); 11886 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it->Type()));
11842 Handle<JSObject> scope_object = it->ScopeObject(); 11887 Handle<JSObject> scope_object = it->ScopeObject();
11843 RETURN_IF_EMPTY_HANDLE(isolate, scope_object); 11888 RETURN_IF_EMPTY_HANDLE(isolate, scope_object);
11844 details->set(kScopeDetailsObjectIndex, *scope_object); 11889 details->set(kScopeDetailsObjectIndex, *scope_object);
11845 11890
11846 return *isolate->factory()->NewJSArrayWithElements(details); 11891 return *isolate->factory()->NewJSArrayWithElements(details);
11847 } 11892 }
11848 11893
11894
11849 // Return an array with scope details 11895 // Return an array with scope details
11850 // args[0]: number: break id 11896 // args[0]: number: break id
11851 // args[1]: number: frame index 11897 // args[1]: number: frame index
11852 // args[2]: number: inlined frame index 11898 // args[2]: number: inlined frame index
11853 // args[3]: number: scope index 11899 // args[3]: number: scope index
11854 // 11900 //
11855 // The array returned contains the following information: 11901 // The array returned contains the following information:
11856 // 0: Scope type 11902 // 0: Scope type
11857 // 1: Scope object 11903 // 1: Scope object
11858 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { 11904 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
12090 // args[0]: disable break state 12136 // args[0]: disable break state
12091 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { 12137 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) {
12092 HandleScope scope(isolate); 12138 HandleScope scope(isolate);
12093 ASSERT(args.length() == 1); 12139 ASSERT(args.length() == 1);
12094 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); 12140 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0);
12095 isolate->debug()->set_disable_break(disable_break); 12141 isolate->debug()->set_disable_break(disable_break);
12096 return isolate->heap()->undefined_value(); 12142 return isolate->heap()->undefined_value();
12097 } 12143 }
12098 12144
12099 12145
12146 static bool IsPositionAlignmentCodeCorrect(int alignment) {
12147 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED;
12148 }
12149
12150
12100 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { 12151 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) {
12101 HandleScope scope(isolate); 12152 HandleScope scope(isolate);
12102 ASSERT(args.length() == 1); 12153 ASSERT(args.length() == 2);
12103 12154
12104 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 12155 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
12156 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]);
12157
12158 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
12159 return isolate->ThrowIllegalOperation();
12160 }
12161 BreakPositionAlignment alignment =
12162 static_cast<BreakPositionAlignment>(statement_aligned_code);
12163
12105 Handle<SharedFunctionInfo> shared(fun->shared()); 12164 Handle<SharedFunctionInfo> shared(fun->shared());
12106 // Find the number of break points 12165 // Find the number of break points
12107 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); 12166 Handle<Object> break_locations =
12167 Debug::GetSourceBreakLocations(shared, alignment);
12108 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); 12168 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value();
12109 // Return array as JS array 12169 // Return array as JS array
12110 return *isolate->factory()->NewJSArrayWithElements( 12170 return *isolate->factory()->NewJSArrayWithElements(
12111 Handle<FixedArray>::cast(break_locations)); 12171 Handle<FixedArray>::cast(break_locations));
12112 } 12172 }
12113 12173
12114 12174
12115 // Set a break point in a function. 12175 // Set a break point in a function.
12116 // args[0]: function 12176 // args[0]: function
12117 // args[1]: number: break source position (within the function source) 12177 // args[1]: number: break source position (within the function source)
(...skipping 12 matching lines...) Expand all
12130 12190
12131 return Smi::FromInt(source_position); 12191 return Smi::FromInt(source_position);
12132 } 12192 }
12133 12193
12134 12194
12135 // Changes the state of a break point in a script and returns source position 12195 // Changes the state of a break point in a script and returns source position
12136 // where break point was set. NOTE: Regarding performance see the NOTE for 12196 // where break point was set. NOTE: Regarding performance see the NOTE for
12137 // GetScriptFromScriptData. 12197 // GetScriptFromScriptData.
12138 // args[0]: script to set break point in 12198 // args[0]: script to set break point in
12139 // args[1]: number: break source position (within the script source) 12199 // args[1]: number: break source position (within the script source)
12140 // args[2]: number: break point object 12200 // args[2]: number, breakpoint position alignment
12201 // args[3]: number: break point object
12141 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { 12202 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) {
12142 HandleScope scope(isolate); 12203 HandleScope scope(isolate);
12143 ASSERT(args.length() == 3); 12204 ASSERT(args.length() == 4);
12144 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); 12205 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
12145 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); 12206 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
12146 RUNTIME_ASSERT(source_position >= 0); 12207 RUNTIME_ASSERT(source_position >= 0);
12147 Handle<Object> break_point_object_arg = args.at<Object>(2); 12208 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]);
12209 Handle<Object> break_point_object_arg = args.at<Object>(3);
12210
12211 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
12212 return isolate->ThrowIllegalOperation();
12213 }
12214 BreakPositionAlignment alignment =
12215 static_cast<BreakPositionAlignment>(statement_aligned_code);
12148 12216
12149 // Get the script from the script wrapper. 12217 // Get the script from the script wrapper.
12150 RUNTIME_ASSERT(wrapper->value()->IsScript()); 12218 RUNTIME_ASSERT(wrapper->value()->IsScript());
12151 Handle<Script> script(Script::cast(wrapper->value())); 12219 Handle<Script> script(Script::cast(wrapper->value()));
12152 12220
12153 // Set break point. 12221 // Set break point.
12154 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, 12222 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
12155 &source_position)) { 12223 &source_position,
12224 alignment)) {
12156 return isolate->heap()->undefined_value(); 12225 return isolate->heap()->undefined_value();
12157 } 12226 }
12158 12227
12159 return Smi::FromInt(source_position); 12228 return Smi::FromInt(source_position);
12160 } 12229 }
12161 12230
12162 12231
12163 // Clear a break point 12232 // Clear a break point
12164 // args[0]: number: break point object 12233 // args[0]: number: break point object
12165 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { 12234 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
12380 context = isolate->factory()->NewWithContext(closure, context, extension); 12449 context = isolate->factory()->NewWithContext(closure, context, extension);
12381 } 12450 }
12382 12451
12383 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 12452 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(
12384 source, 12453 source,
12385 context, 12454 context,
12386 context->IsNativeContext(), 12455 context->IsNativeContext(),
12387 CLASSIC_MODE, 12456 CLASSIC_MODE,
12388 NO_PARSE_RESTRICTION, 12457 NO_PARSE_RESTRICTION,
12389 RelocInfo::kNoPosition); 12458 RelocInfo::kNoPosition);
12390 if (shared.is_null()) return Failure::Exception(); 12459 RETURN_IF_EMPTY_HANDLE(isolate, shared);
12391 12460
12392 Handle<JSFunction> eval_fun = 12461 Handle<JSFunction> eval_fun =
12393 isolate->factory()->NewFunctionFromSharedFunctionInfo( 12462 isolate->factory()->NewFunctionFromSharedFunctionInfo(
12394 shared, context, NOT_TENURED); 12463 shared, context, NOT_TENURED);
12395 bool pending_exception; 12464 bool pending_exception;
12396 Handle<Object> result = Execution::Call( 12465 Handle<Object> result = Execution::Call(
12397 eval_fun, receiver, 0, NULL, &pending_exception); 12466 eval_fun, receiver, 0, NULL, &pending_exception);
12398 12467
12399 if (pending_exception) return Failure::Exception(); 12468 if (pending_exception) return Failure::Exception();
12400 12469
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
12922 continue; 12991 continue;
12923 } 12992 }
12924 if (counter < buffer_size) { 12993 if (counter < buffer_size) {
12925 buffer->set(counter, shared); 12994 buffer->set(counter, shared);
12926 } 12995 }
12927 counter++; 12996 counter++;
12928 } 12997 }
12929 return counter; 12998 return counter;
12930 } 12999 }
12931 13000
13001
12932 // For a script finds all SharedFunctionInfo's in the heap that points 13002 // For a script finds all SharedFunctionInfo's in the heap that points
12933 // to this script. Returns JSArray of SharedFunctionInfo wrapped 13003 // to this script. Returns JSArray of SharedFunctionInfo wrapped
12934 // in OpaqueReferences. 13004 // in OpaqueReferences.
12935 RUNTIME_FUNCTION(MaybeObject*, 13005 RUNTIME_FUNCTION(MaybeObject*,
12936 Runtime_LiveEditFindSharedFunctionInfosForScript) { 13006 Runtime_LiveEditFindSharedFunctionInfosForScript) {
12937 HandleScope scope(isolate); 13007 HandleScope scope(isolate);
12938 CHECK(isolate->debugger()->live_edit_enabled()); 13008 CHECK(isolate->debugger()->live_edit_enabled());
12939 ASSERT(args.length() == 1); 13009 ASSERT(args.length() == 1);
12940 CONVERT_ARG_CHECKED(JSValue, script_value, 0); 13010 CONVERT_ARG_CHECKED(JSValue, script_value, 0);
12941 13011
(...skipping 25 matching lines...) Expand all
12967 } 13037 }
12968 13038
12969 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array); 13039 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(array);
12970 result->set_length(Smi::FromInt(number)); 13040 result->set_length(Smi::FromInt(number));
12971 13041
12972 LiveEdit::WrapSharedFunctionInfos(result); 13042 LiveEdit::WrapSharedFunctionInfos(result);
12973 13043
12974 return *result; 13044 return *result;
12975 } 13045 }
12976 13046
13047
12977 // For a script calculates compilation information about all its functions. 13048 // For a script calculates compilation information about all its functions.
12978 // The script source is explicitly specified by the second argument. 13049 // The script source is explicitly specified by the second argument.
12979 // The source of the actual script is not used, however it is important that 13050 // The source of the actual script is not used, however it is important that
12980 // all generated code keeps references to this particular instance of script. 13051 // all generated code keeps references to this particular instance of script.
12981 // Returns a JSArray of compilation infos. The array is ordered so that 13052 // Returns a JSArray of compilation infos. The array is ordered so that
12982 // each function with all its descendant is always stored in a continues range 13053 // each function with all its descendant is always stored in a continues range
12983 // with the function itself going first. The root function is a script function. 13054 // with the function itself going first. The root function is a script function.
12984 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { 13055 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) {
12985 HandleScope scope(isolate); 13056 HandleScope scope(isolate);
12986 CHECK(isolate->debugger()->live_edit_enabled()); 13057 CHECK(isolate->debugger()->live_edit_enabled());
12987 ASSERT(args.length() == 2); 13058 ASSERT(args.length() == 2);
12988 CONVERT_ARG_CHECKED(JSValue, script, 0); 13059 CONVERT_ARG_CHECKED(JSValue, script, 0);
12989 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 13060 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
12990 13061
12991 RUNTIME_ASSERT(script->value()->IsScript()); 13062 RUNTIME_ASSERT(script->value()->IsScript());
12992 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); 13063 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
12993 13064
12994 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); 13065 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source);
12995 13066
12996 if (isolate->has_pending_exception()) { 13067 if (isolate->has_pending_exception()) {
12997 return Failure::Exception(); 13068 return Failure::Exception();
12998 } 13069 }
12999 13070
13000 return result; 13071 return result;
13001 } 13072 }
13002 13073
13074
13003 // Changes the source of the script to a new_source. 13075 // Changes the source of the script to a new_source.
13004 // If old_script_name is provided (i.e. is a String), also creates a copy of 13076 // If old_script_name is provided (i.e. is a String), also creates a copy of
13005 // the script with its original source and sends notification to debugger. 13077 // the script with its original source and sends notification to debugger.
13006 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { 13078 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) {
13007 HandleScope scope(isolate); 13079 HandleScope scope(isolate);
13008 CHECK(isolate->debugger()->live_edit_enabled()); 13080 CHECK(isolate->debugger()->live_edit_enabled());
13009 ASSERT(args.length() == 3); 13081 ASSERT(args.length() == 3);
13010 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); 13082 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0);
13011 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); 13083 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1);
13012 Handle<Object> old_script_name(args[2], isolate); 13084 Handle<Object> old_script_name(args[2], isolate);
(...skipping 27 matching lines...) Expand all
13040 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) { 13112 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) {
13041 HandleScope scope(isolate); 13113 HandleScope scope(isolate);
13042 CHECK(isolate->debugger()->live_edit_enabled()); 13114 CHECK(isolate->debugger()->live_edit_enabled());
13043 ASSERT(args.length() == 2); 13115 ASSERT(args.length() == 2);
13044 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); 13116 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0);
13045 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); 13117 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1);
13046 13118
13047 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); 13119 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info);
13048 } 13120 }
13049 13121
13122
13050 // Connects SharedFunctionInfo to another script. 13123 // Connects SharedFunctionInfo to another script.
13051 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { 13124 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) {
13052 HandleScope scope(isolate); 13125 HandleScope scope(isolate);
13053 CHECK(isolate->debugger()->live_edit_enabled()); 13126 CHECK(isolate->debugger()->live_edit_enabled());
13054 ASSERT(args.length() == 2); 13127 ASSERT(args.length() == 2);
13055 Handle<Object> function_object(args[0], isolate); 13128 Handle<Object> function_object(args[0], isolate);
13056 Handle<Object> script_object(args[1], isolate); 13129 Handle<Object> script_object(args[1], isolate);
13057 13130
13058 if (function_object->IsJSValue()) { 13131 if (function_object->IsJSValue()) {
13059 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); 13132 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
13114 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { 13187 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) {
13115 HandleScope scope(isolate); 13188 HandleScope scope(isolate);
13116 CHECK(isolate->debugger()->live_edit_enabled()); 13189 CHECK(isolate->debugger()->live_edit_enabled());
13117 ASSERT(args.length() == 2); 13190 ASSERT(args.length() == 2);
13118 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); 13191 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
13119 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); 13192 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1);
13120 13193
13121 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); 13194 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop);
13122 } 13195 }
13123 13196
13197
13124 // Compares 2 strings line-by-line, then token-wise and returns diff in form 13198 // Compares 2 strings line-by-line, then token-wise and returns diff in form
13125 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list 13199 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list
13126 // of diff chunks. 13200 // of diff chunks.
13127 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { 13201 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) {
13128 HandleScope scope(isolate); 13202 HandleScope scope(isolate);
13129 CHECK(isolate->debugger()->live_edit_enabled()); 13203 CHECK(isolate->debugger()->live_edit_enabled());
13130 ASSERT(args.length() == 2); 13204 ASSERT(args.length() == 2);
13131 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); 13205 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
13132 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); 13206 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1);
13133 13207
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
13758 } else { 13832 } else {
13759 // Non-smi length argument produces a dictionary 13833 // Non-smi length argument produces a dictionary
13760 can_use_type_feedback = false; 13834 can_use_type_feedback = false;
13761 } 13835 }
13762 } 13836 }
13763 13837
13764 JSArray* array; 13838 JSArray* array;
13765 MaybeObject* maybe_array; 13839 MaybeObject* maybe_array;
13766 if (!type_info.is_null() && 13840 if (!type_info.is_null() &&
13767 *type_info != isolate->heap()->undefined_value() && 13841 *type_info != isolate->heap()->undefined_value() &&
13768 Cell::cast(*type_info)->value()->IsSmi() && 13842 Cell::cast(*type_info)->value()->IsAllocationSite() &&
13769 can_use_type_feedback) { 13843 can_use_type_feedback) {
13770 Cell* cell = Cell::cast(*type_info); 13844 Handle<Cell> cell = Handle<Cell>::cast(type_info);
13771 Smi* smi = Smi::cast(cell->value()); 13845 Handle<AllocationSite> site = Handle<AllocationSite>(
13772 ElementsKind to_kind = static_cast<ElementsKind>(smi->value()); 13846 AllocationSite::cast(cell->value()), isolate);
13847 ASSERT(!site->IsLiteralSite());
13848 ElementsKind to_kind = site->GetElementsKindPayload();
13773 if (holey && !IsFastHoleyElementsKind(to_kind)) { 13849 if (holey && !IsFastHoleyElementsKind(to_kind)) {
13774 to_kind = GetHoleyElementsKind(to_kind); 13850 to_kind = GetHoleyElementsKind(to_kind);
13775 // Update the allocation site info to reflect the advice alteration. 13851 // Update the allocation site info to reflect the advice alteration.
13776 cell->set_value(Smi::FromInt(to_kind)); 13852 site->SetElementsKindPayload(to_kind);
13777 } 13853 }
13778 13854
13779 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( 13855 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite(
13780 *constructor, type_info); 13856 *constructor, site);
13781 if (!maybe_array->To(&array)) return maybe_array; 13857 if (!maybe_array->To(&array)) return maybe_array;
13782 } else { 13858 } else {
13783 maybe_array = isolate->heap()->AllocateJSObject(*constructor); 13859 maybe_array = isolate->heap()->AllocateJSObject(*constructor);
13784 if (!maybe_array->To(&array)) return maybe_array; 13860 if (!maybe_array->To(&array)) return maybe_array;
13785 // We might need to transition to holey 13861 // We might need to transition to holey
13786 ElementsKind kind = constructor->initial_map()->elements_kind(); 13862 ElementsKind kind = constructor->initial_map()->elements_kind();
13787 if (holey && !IsFastHoleyElementsKind(kind)) { 13863 if (holey && !IsFastHoleyElementsKind(kind)) {
13788 kind = GetHoleyElementsKind(kind); 13864 kind = GetHoleyElementsKind(kind);
13789 maybe_array = array->TransitionElementsKind(kind); 13865 maybe_array = array->TransitionElementsKind(kind);
13790 if (maybe_array->IsFailure()) return maybe_array; 13866 if (maybe_array->IsFailure()) return maybe_array;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
13919 // Handle last resort GC and make sure to allow future allocations 13995 // Handle last resort GC and make sure to allow future allocations
13920 // to grow the heap without causing GCs (if possible). 13996 // to grow the heap without causing GCs (if possible).
13921 isolate->counters()->gc_last_resort_from_js()->Increment(); 13997 isolate->counters()->gc_last_resort_from_js()->Increment();
13922 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13998 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13923 "Runtime::PerformGC"); 13999 "Runtime::PerformGC");
13924 } 14000 }
13925 } 14001 }
13926 14002
13927 14003
13928 } } // namespace v8::internal 14004 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698