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

Side by Side Diff: src/runtime.cc

Issue 133443009: A64: Synchronize with r17441. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <limits> 29 #include <limits>
30 30
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #include "accessors.h" 33 #include "accessors.h"
34 #include "allocation-site-scopes.h"
34 #include "api.h" 35 #include "api.h"
35 #include "arguments.h" 36 #include "arguments.h"
36 #include "bootstrapper.h" 37 #include "bootstrapper.h"
37 #include "codegen.h" 38 #include "codegen.h"
38 #include "compilation-cache.h" 39 #include "compilation-cache.h"
39 #include "compiler.h" 40 #include "compiler.h"
40 #include "cpu.h" 41 #include "cpu.h"
41 #include "cpu-profiler.h" 42 #include "cpu-profiler.h"
42 #include "dateparser-inl.h" 43 #include "dateparser-inl.h"
43 #include "debug.h" 44 #include "debug.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 HandleScope scope(isolate); 480 HandleScope scope(isolate);
480 ASSERT(args.length() == 4); 481 ASSERT(args.length() == 4);
481 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 482 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
482 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 483 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
483 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); 484 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2);
484 CONVERT_SMI_ARG_CHECKED(flags, 3); 485 CONVERT_SMI_ARG_CHECKED(flags, 3);
485 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; 486 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
486 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; 487 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
487 488
488 // Check if boilerplate exists. If not, create it first. 489 // Check if boilerplate exists. If not, create it first.
489 Handle<Object> boilerplate(literals->get(literals_index), isolate); 490 Handle<Object> literal_site(literals->get(literals_index), isolate);
490 if (*boilerplate == isolate->heap()->undefined_value()) { 491 Handle<AllocationSite> site;
491 boilerplate = CreateObjectLiteralBoilerplate(isolate, 492 Handle<JSObject> boilerplate;
492 literals, 493 if (*literal_site == isolate->heap()->undefined_value()) {
493 constant_properties, 494 Handle<Object> raw_boilerplate = CreateObjectLiteralBoilerplate(
494 should_have_fast_elements, 495 isolate,
495 has_function_literal); 496 literals,
496 RETURN_IF_EMPTY_HANDLE(isolate, boilerplate); 497 constant_properties,
498 should_have_fast_elements,
499 has_function_literal);
500 RETURN_IF_EMPTY_HANDLE(isolate, raw_boilerplate);
501 boilerplate = Handle<JSObject>::cast(raw_boilerplate);
502
503 AllocationSiteCreationContext creation_context(isolate);
504 site = creation_context.EnterNewScope();
505 RETURN_IF_EMPTY_HANDLE(isolate,
506 JSObject::DeepWalk(boilerplate, &creation_context));
507 creation_context.ExitScope(site, boilerplate);
508
497 // Update the functions literal and return the boilerplate. 509 // Update the functions literal and return the boilerplate.
498 literals->set(literals_index, *boilerplate); 510 literals->set(literals_index, *site);
511 } else {
512 site = Handle<AllocationSite>::cast(literal_site);
513 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()),
514 isolate);
499 } 515 }
500 516
501 Handle<Object> copy = JSObject::DeepCopy(Handle<JSObject>::cast(boilerplate)); 517 AllocationSiteUsageContext usage_context(isolate, site, true);
518 usage_context.EnterNewScope();
519 Handle<Object> copy = JSObject::DeepCopy(boilerplate, &usage_context);
520 usage_context.ExitScope(site, boilerplate);
502 RETURN_IF_EMPTY_HANDLE(isolate, copy); 521 RETURN_IF_EMPTY_HANDLE(isolate, copy);
503 return *copy; 522 return *copy;
504 } 523 }
505 524
506 525
507 static Handle<AllocationSite> GetLiteralAllocationSite( 526 static Handle<AllocationSite> GetLiteralAllocationSite(
508 Isolate* isolate, 527 Isolate* isolate,
509 Handle<FixedArray> literals, 528 Handle<FixedArray> literals,
510 int literals_index, 529 int literals_index,
511 Handle<FixedArray> elements) { 530 Handle<FixedArray> elements) {
512 // Check if boilerplate exists. If not, create it first. 531 // Check if boilerplate exists. If not, create it first.
513 Handle<Object> literal_site(literals->get(literals_index), isolate); 532 Handle<Object> literal_site(literals->get(literals_index), isolate);
514 Handle<AllocationSite> site; 533 Handle<AllocationSite> site;
515 if (*literal_site == isolate->heap()->undefined_value()) { 534 if (*literal_site == isolate->heap()->undefined_value()) {
516 ASSERT(*elements != isolate->heap()->empty_fixed_array()); 535 ASSERT(*elements != isolate->heap()->empty_fixed_array());
517 Handle<Object> boilerplate = 536 Handle<Object> boilerplate =
518 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements); 537 Runtime::CreateArrayLiteralBoilerplate(isolate, literals, elements);
519 if (boilerplate.is_null()) { 538 if (boilerplate.is_null()) return Handle<AllocationSite>::null();
520 ASSERT(site.is_null()); 539
521 return site; 540 AllocationSiteCreationContext creation_context(isolate);
541 site = creation_context.EnterNewScope();
542 if (JSObject::DeepWalk(Handle<JSObject>::cast(boilerplate),
543 &creation_context).is_null()) {
544 return Handle<AllocationSite>::null();
522 } 545 }
523 site = isolate->factory()->NewAllocationSite(); 546 creation_context.ExitScope(site, Handle<JSObject>::cast(boilerplate));
524 site->set_transition_info(*boilerplate); 547
525 literals->set(literals_index, *site); 548 literals->set(literals_index, *site);
526 } else { 549 } else {
527 site = Handle<AllocationSite>::cast(literal_site); 550 site = Handle<AllocationSite>::cast(literal_site);
528 } 551 }
529 552
530 return site; 553 return site;
531 } 554 }
532 555
533 556
534 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { 557 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
535 HandleScope scope(isolate); 558 HandleScope scope(isolate);
536 ASSERT(args.length() == 3); 559 ASSERT(args.length() == 3);
537 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 560 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
538 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 561 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
539 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 562 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
540 563
541 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, 564 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
542 literals_index, elements); 565 literals_index, elements);
543 RETURN_IF_EMPTY_HANDLE(isolate, site); 566 RETURN_IF_EMPTY_HANDLE(isolate, site);
544 567
545 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info())); 568 Handle<JSObject> boilerplate(JSObject::cast(site->transition_info()));
546 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate); 569 AllocationSiteUsageContext usage_context(isolate, site, true);
570 usage_context.EnterNewScope();
571 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context);
572 usage_context.ExitScope(site, boilerplate);
547 RETURN_IF_EMPTY_HANDLE(isolate, copy); 573 RETURN_IF_EMPTY_HANDLE(isolate, copy);
548 return *copy; 574 return *copy;
549 } 575 }
550 576
551 577
552 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { 578 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
553 HandleScope scope(isolate); 579 HandleScope scope(isolate);
554 ASSERT(args.length() == 3); 580 ASSERT(args.length() == 3);
555 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); 581 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
556 CONVERT_SMI_ARG_CHECKED(literals_index, 1); 582 CONVERT_SMI_ARG_CHECKED(literals_index, 1);
557 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); 583 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
558 584
559 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals, 585 Handle<AllocationSite> site = GetLiteralAllocationSite(isolate, literals,
560 literals_index, elements); 586 literals_index, elements);
561 RETURN_IF_EMPTY_HANDLE(isolate, site); 587 RETURN_IF_EMPTY_HANDLE(isolate, site);
562 588
563 JSObject* boilerplate = JSObject::cast(site->transition_info()); 589 JSObject* boilerplate = JSObject::cast(site->transition_info());
564 if (boilerplate->elements()->map() == 590 if (boilerplate->elements()->map() ==
565 isolate->heap()->fixed_cow_array_map()) { 591 isolate->heap()->fixed_cow_array_map()) {
566 isolate->counters()->cow_arrays_created_runtime()->Increment(); 592 isolate->counters()->cow_arrays_created_runtime()->Increment();
567 } 593 }
568 594
569 AllocationSiteMode mode = AllocationSite::GetMode( 595 if (AllocationSite::GetMode(boilerplate->GetElementsKind()) ==
570 boilerplate->GetElementsKind()); 596 TRACK_ALLOCATION_SITE) {
571 if (mode == TRACK_ALLOCATION_SITE) {
572 return isolate->heap()->CopyJSObject(boilerplate, *site); 597 return isolate->heap()->CopyJSObject(boilerplate, *site);
573 } 598 }
574 599
575 return isolate->heap()->CopyJSObject(boilerplate); 600 return isolate->heap()->CopyJSObject(boilerplate);
576 } 601 }
577 602
578 603
579 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { 604 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) {
580 HandleScope scope(isolate); 605 HandleScope scope(isolate);
581 ASSERT(args.length() == 1); 606 ASSERT(args.length() == 1);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 if (target_length == 0) return isolate->heap()->undefined_value(); 819 if (target_length == 0) return isolate->heap()->undefined_value();
795 820
796 ASSERT(NumberToSize(isolate, source->byte_length()) - target_length >= start); 821 ASSERT(NumberToSize(isolate, source->byte_length()) - target_length >= start);
797 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); 822 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store());
798 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); 823 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store());
799 CopyBytes(target_data, source_data + start, target_length); 824 CopyBytes(target_data, source_data + start, target_length);
800 return isolate->heap()->undefined_value(); 825 return isolate->heap()->undefined_value();
801 } 826 }
802 827
803 828
829 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) {
830 HandleScope scope(isolate);
831 ASSERT(args.length() == 1);
832 CONVERT_ARG_CHECKED(Object, object, 0);
833 return object->IsJSArrayBufferView()
834 ? isolate->heap()->true_value()
835 : isolate->heap()->false_value();
836 }
837
838
804 enum TypedArrayId { 839 enum TypedArrayId {
805 // arrayIds below should be synchromized with typedarray.js natives. 840 // arrayIds below should be synchromized with typedarray.js natives.
806 ARRAY_ID_UINT8 = 1, 841 ARRAY_ID_UINT8 = 1,
807 ARRAY_ID_INT8 = 2, 842 ARRAY_ID_INT8 = 2,
808 ARRAY_ID_UINT16 = 3, 843 ARRAY_ID_UINT16 = 3,
809 ARRAY_ID_INT16 = 4, 844 ARRAY_ID_INT16 = 4,
810 ARRAY_ID_UINT32 = 5, 845 ARRAY_ID_UINT32 = 5,
811 ARRAY_ID_INT32 = 6, 846 ARRAY_ID_INT32 = 6,
812 ARRAY_ID_FLOAT32 = 7, 847 ARRAY_ID_FLOAT32 = 7,
813 ARRAY_ID_FLOAT64 = 8, 848 ARRAY_ID_FLOAT64 = 8,
(...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 } 2926 }
2892 2927
2893 // Mark both, the source and the target, as un-flushable because the 2928 // Mark both, the source and the target, as un-flushable because the
2894 // shared unoptimized code makes them impossible to enqueue in a list. 2929 // shared unoptimized code makes them impossible to enqueue in a list.
2895 ASSERT(target_shared->code()->gc_metadata() == NULL); 2930 ASSERT(target_shared->code()->gc_metadata() == NULL);
2896 ASSERT(source_shared->code()->gc_metadata() == NULL); 2931 ASSERT(source_shared->code()->gc_metadata() == NULL);
2897 target_shared->set_dont_flush(true); 2932 target_shared->set_dont_flush(true);
2898 source_shared->set_dont_flush(true); 2933 source_shared->set_dont_flush(true);
2899 2934
2900 // Set the code, scope info, formal parameter count, and the length 2935 // Set the code, scope info, formal parameter count, and the length
2901 // of the target shared function info. Set the source code of the 2936 // of the target shared function info.
2902 // target function to undefined. SetCode is only used for built-in
2903 // constructors like String, Array, and Object, and some web code
2904 // doesn't like seeing source code for constructors.
2905 target_shared->ReplaceCode(source_shared->code()); 2937 target_shared->ReplaceCode(source_shared->code());
2906 target_shared->set_scope_info(source_shared->scope_info()); 2938 target_shared->set_scope_info(source_shared->scope_info());
2907 target_shared->set_length(source_shared->length()); 2939 target_shared->set_length(source_shared->length());
2908 target_shared->set_formal_parameter_count( 2940 target_shared->set_formal_parameter_count(
2909 source_shared->formal_parameter_count()); 2941 source_shared->formal_parameter_count());
2910 target_shared->set_script(isolate->heap()->undefined_value()); 2942 target_shared->set_script(source_shared->script());
2911 2943 target_shared->set_start_position_and_type(
2912 // Since we don't store the source we should never optimize this. 2944 source_shared->start_position_and_type());
2913 target_shared->code()->set_optimizable(false); 2945 target_shared->set_end_position(source_shared->end_position());
2946 bool was_native = target_shared->native();
2947 target_shared->set_compiler_hints(source_shared->compiler_hints());
2948 target_shared->set_native(was_native);
2914 2949
2915 // Set the code of the target function. 2950 // Set the code of the target function.
2916 target->ReplaceCode(source_shared->code()); 2951 target->ReplaceCode(source_shared->code());
2917 ASSERT(target->next_function_link()->IsUndefined()); 2952 ASSERT(target->next_function_link()->IsUndefined());
2918 2953
2919 // Make sure we get a fresh copy of the literal vector to avoid cross 2954 // Make sure we get a fresh copy of the literal vector to avoid cross
2920 // context contamination. 2955 // context contamination.
2921 Handle<Context> context(source->context()); 2956 Handle<Context> context(source->context());
2922 int number_of_literals = source->NumberOfLiterals(); 2957 int number_of_literals = source->NumberOfLiterals();
2923 Handle<FixedArray> literals = 2958 Handle<FixedArray> literals =
(...skipping 11 matching lines...) Expand all
2935 source_shared, Handle<Code>(source_shared->code())); 2970 source_shared, Handle<Code>(source_shared->code()));
2936 } 2971 }
2937 2972
2938 return *target; 2973 return *target;
2939 } 2974 }
2940 2975
2941 2976
2942 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { 2977 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) {
2943 HandleScope scope(isolate); 2978 HandleScope scope(isolate);
2944 ASSERT(args.length() == 2); 2979 ASSERT(args.length() == 2);
2945 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 2980 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
2946 CONVERT_SMI_ARG_CHECKED(num, 1); 2981 CONVERT_SMI_ARG_CHECKED(num, 1);
2947 RUNTIME_ASSERT(num >= 0); 2982 RUNTIME_ASSERT(num >= 0);
2948 SetExpectedNofProperties(function, num); 2983 // If objects constructed from this function exist then changing
2984 // 'estimated_nof_properties' is dangerous since the previous value might
2985 // have been compiled into the fast construct stub. Moreover, the inobject
2986 // slack tracking logic might have adjusted the previous value, so even
2987 // passing the same value is risky.
2988 if (!func->shared()->live_objects_may_exist()) {
2989 func->shared()->set_expected_nof_properties(num);
2990 if (func->has_initial_map()) {
2991 Handle<Map> new_initial_map =
2992 func->GetIsolate()->factory()->CopyMap(
2993 Handle<Map>(func->initial_map()));
2994 new_initial_map->set_unused_property_fields(num);
2995 func->set_initial_map(*new_initial_map);
2996 }
2997 }
2949 return isolate->heap()->undefined_value(); 2998 return isolate->heap()->undefined_value();
2950 } 2999 }
2951 3000
2952 3001
2953 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) { 3002 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) {
2954 SealHandleScope shs(isolate); 3003 SealHandleScope shs(isolate);
2955 ASSERT(args.length() == 0); 3004 ASSERT(args.length() == 0);
2956 3005
2957 JavaScriptFrameIterator it(isolate); 3006 JavaScriptFrameIterator it(isolate);
2958 JavaScriptFrame* frame = it.frame(); 3007 JavaScriptFrame* frame = it.frame();
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after
5526 return HasLocalPropertyImplementation(isolate, 5575 return HasLocalPropertyImplementation(isolate,
5527 Handle<JSObject>::cast(proto), 5576 Handle<JSObject>::cast(proto),
5528 key); 5577 key);
5529 } 5578 }
5530 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5579 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5531 return isolate->heap()->false_value(); 5580 return isolate->heap()->false_value();
5532 } 5581 }
5533 5582
5534 5583
5535 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { 5584 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
5536 SealHandleScope shs(isolate); 5585 HandleScope scope(isolate);
5537 ASSERT(args.length() == 2); 5586 ASSERT(args.length() == 2);
5538 CONVERT_ARG_CHECKED(Name, key, 1); 5587 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5588 Handle<Object> object = args.at<Object>(0);
5539 5589
5540 uint32_t index; 5590 uint32_t index;
5541 const bool key_is_array_index = key->AsArrayIndex(&index); 5591 const bool key_is_array_index = key->AsArrayIndex(&index);
5542 5592
5543 Object* obj = args[0];
5544 // Only JS objects can have properties. 5593 // Only JS objects can have properties.
5545 if (obj->IsJSObject()) { 5594 if (object->IsJSObject()) {
5546 JSObject* object = JSObject::cast(obj); 5595 Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
5547 // Fast case: either the key is a real named property or it is not 5596 // Fast case: either the key is a real named property or it is not
5548 // an array index and there are no interceptors or hidden 5597 // an array index and there are no interceptors or hidden
5549 // prototypes. 5598 // prototypes.
5550 if (object->HasRealNamedProperty(isolate, key)) { 5599 if (JSObject::HasRealNamedProperty(js_obj, key)) {
5551 ASSERT(!isolate->has_scheduled_exception()); 5600 ASSERT(!isolate->has_scheduled_exception());
5552 return isolate->heap()->true_value(); 5601 return isolate->heap()->true_value();
5553 } else { 5602 } else {
5554 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5603 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5555 } 5604 }
5556 Map* map = object->map(); 5605 Map* map = js_obj->map();
5557 if (!key_is_array_index && 5606 if (!key_is_array_index &&
5558 !map->has_named_interceptor() && 5607 !map->has_named_interceptor() &&
5559 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { 5608 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) {
5560 return isolate->heap()->false_value(); 5609 return isolate->heap()->false_value();
5561 } 5610 }
5562 // Slow case. 5611 // Slow case.
5563 HandleScope scope(isolate);
5564 return HasLocalPropertyImplementation(isolate, 5612 return HasLocalPropertyImplementation(isolate,
5565 Handle<JSObject>(object), 5613 Handle<JSObject>(js_obj),
5566 Handle<Name>(key)); 5614 Handle<Name>(key));
5567 } else if (obj->IsString() && key_is_array_index) { 5615 } else if (object->IsString() && key_is_array_index) {
5568 // Well, there is one exception: Handle [] on strings. 5616 // Well, there is one exception: Handle [] on strings.
5569 String* string = String::cast(obj); 5617 Handle<String> string = Handle<String>::cast(object);
5570 if (index < static_cast<uint32_t>(string->length())) { 5618 if (index < static_cast<uint32_t>(string->length())) {
5571 return isolate->heap()->true_value(); 5619 return isolate->heap()->true_value();
5572 } 5620 }
5573 } 5621 }
5574 return isolate->heap()->false_value(); 5622 return isolate->heap()->false_value();
5575 } 5623 }
5576 5624
5577 5625
5578 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { 5626 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
5579 HandleScope scope(isolate); 5627 HandleScope scope(isolate);
(...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after
8291 8339
8292 8340
8293 bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) { 8341 bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) {
8294 // If the function is not compiled ignore the lazy 8342 // If the function is not compiled ignore the lazy
8295 // recompilation. This can happen if the debugger is activated and 8343 // recompilation. This can happen if the debugger is activated and
8296 // the function is returned to the not compiled state. 8344 // the function is returned to the not compiled state.
8297 if (!function->shared()->is_compiled()) return false; 8345 if (!function->shared()->is_compiled()) return false;
8298 8346
8299 // If the function is not optimizable or debugger is active continue using the 8347 // If the function is not optimizable or debugger is active continue using the
8300 // code from the full compiler. 8348 // code from the full compiler.
8301 if (!FLAG_crankshaft || 8349 if (!isolate->use_crankshaft() ||
8302 function->shared()->optimization_disabled() || 8350 function->shared()->optimization_disabled() ||
8303 isolate->DebuggerHasBreakPoints()) { 8351 isolate->DebuggerHasBreakPoints()) {
8304 if (FLAG_trace_opt) { 8352 if (FLAG_trace_opt) {
8305 PrintF("[failed to optimize "); 8353 PrintF("[failed to optimize ");
8306 function->PrintName(); 8354 function->PrintName();
8307 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", 8355 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n",
8308 function->shared()->optimization_disabled() ? "F" : "T", 8356 function->shared()->optimization_disabled() ? "F" : "T",
8309 isolate->DebuggerHasBreakPoints() ? "T" : "F"); 8357 isolate->DebuggerHasBreakPoints() ? "T" : "F");
8310 } 8358 }
8311 return false; 8359 return false;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
8554 : Smi::FromInt(2); // 2 == "no". 8602 : Smi::FromInt(2); // 2 == "no".
8555 } 8603 }
8556 if (FLAG_deopt_every_n_times) { 8604 if (FLAG_deopt_every_n_times) {
8557 return Smi::FromInt(6); // 6 == "maybe deopted". 8605 return Smi::FromInt(6); // 6 == "maybe deopted".
8558 } 8606 }
8559 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". 8607 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
8560 : Smi::FromInt(2); // 2 == "no". 8608 : Smi::FromInt(2); // 2 == "no".
8561 } 8609 }
8562 8610
8563 8611
8612 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnblockConcurrentRecompilation) {
8613 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation);
8614 isolate->optimizing_compiler_thread()->Unblock();
8615 return isolate->heap()->undefined_value();
8616 }
8617
8618
8564 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { 8619 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) {
8565 HandleScope scope(isolate); 8620 HandleScope scope(isolate);
8566 ASSERT(args.length() == 1); 8621 ASSERT(args.length() == 1);
8567 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8622 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8568 return Smi::FromInt(function->shared()->opt_count()); 8623 return Smi::FromInt(function->shared()->opt_count());
8569 } 8624 }
8570 8625
8571 8626
8572 static bool IsSuitableForOnStackReplacement(Isolate* isolate, 8627 static bool IsSuitableForOnStackReplacement(Isolate* isolate,
8573 Handle<JSFunction> function, 8628 Handle<JSFunction> function,
8574 Handle<Code> unoptimized) { 8629 Handle<Code> unoptimized) {
8575 // Keep track of whether we've succeeded in optimizing. 8630 // Keep track of whether we've succeeded in optimizing.
8576 if (!unoptimized->optimizable()) return false; 8631 if (!isolate->use_crankshaft() || !unoptimized->optimizable()) return false;
8577 // If we are trying to do OSR when there are already optimized 8632 // If we are trying to do OSR when there are already optimized
8578 // activations of the function, it means (a) the function is directly or 8633 // activations of the function, it means (a) the function is directly or
8579 // indirectly recursive and (b) an optimized invocation has been 8634 // indirectly recursive and (b) an optimized invocation has been
8580 // deoptimized so that we are currently in an unoptimized activation. 8635 // deoptimized so that we are currently in an unoptimized activation.
8581 // Check for optimized activations of this function. 8636 // Check for optimized activations of this function.
8582 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { 8637 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
8583 JavaScriptFrame* frame = it.frame(); 8638 JavaScriptFrame* frame = it.frame();
8584 if (frame->is_optimized() && frame->function() == *function) return false; 8639 if (frame->is_optimized() && frame->function() == *function) return false;
8585 } 8640 }
8586 8641
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after
10486 return string; 10541 return string;
10487 } 10542 }
10488 10543
10489 10544
10490 // Moves all own elements of an object, that are below a limit, to positions 10545 // Moves all own elements of an object, that are below a limit, to positions
10491 // starting at zero. All undefined values are placed after non-undefined values, 10546 // starting at zero. All undefined values are placed after non-undefined values,
10492 // and are followed by non-existing element. Does not change the length 10547 // and are followed by non-existing element. Does not change the length
10493 // property. 10548 // property.
10494 // Returns the number of non-undefined elements collected. 10549 // Returns the number of non-undefined elements collected.
10495 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { 10550 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) {
10496 SealHandleScope shs(isolate); 10551 HandleScope scope(isolate);
10497 ASSERT(args.length() == 2); 10552 ASSERT(args.length() == 2);
10498 CONVERT_ARG_CHECKED(JSObject, object, 0); 10553 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
10499 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 10554 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
10500 return object->PrepareElementsForSort(limit); 10555 return *JSObject::PrepareElementsForSort(object, limit);
10501 } 10556 }
10502 10557
10503 10558
10504 // Move contents of argument 0 (an array) to argument 1 (an array) 10559 // Move contents of argument 0 (an array) to argument 1 (an array)
10505 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { 10560 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) {
10506 SealHandleScope shs(isolate); 10561 SealHandleScope shs(isolate);
10507 ASSERT(args.length() == 2); 10562 ASSERT(args.length() == 2);
10508 CONVERT_ARG_CHECKED(JSArray, from, 0); 10563 CONVERT_ARG_CHECKED(JSArray, from, 0);
10509 CONVERT_ARG_CHECKED(JSArray, to, 1); 10564 CONVERT_ARG_CHECKED(JSArray, to, 1);
10510 from->ValidateElements(); 10565 from->ValidateElements();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
10671 if (value->IsTheHole()) { 10726 if (value->IsTheHole()) {
10672 return heap->undefined_value(); 10727 return heap->undefined_value();
10673 } 10728 }
10674 return value; 10729 return value;
10675 } 10730 }
10676 case CONSTANT: 10731 case CONSTANT:
10677 return result->GetConstant(); 10732 return result->GetConstant();
10678 case CALLBACKS: { 10733 case CALLBACKS: {
10679 Object* structure = result->GetCallbackObject(); 10734 Object* structure = result->GetCallbackObject();
10680 if (structure->IsForeign() || structure->IsAccessorInfo()) { 10735 if (structure->IsForeign() || structure->IsAccessorInfo()) {
10681 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( 10736 Isolate* isolate = heap->isolate();
10682 receiver, structure, name); 10737 HandleScope scope(isolate);
10683 if (!maybe_value->ToObject(&value)) { 10738 Handle<Object> value = JSObject::GetPropertyWithCallback(
10684 if (maybe_value->IsRetryAfterGC()) return maybe_value; 10739 handle(result->holder(), isolate),
10685 ASSERT(maybe_value->IsException()); 10740 handle(receiver, isolate),
10686 maybe_value = heap->isolate()->pending_exception(); 10741 handle(structure, isolate),
10742 handle(name, isolate));
10743 if (value.is_null()) {
10744 MaybeObject* exception = heap->isolate()->pending_exception();
10687 heap->isolate()->clear_pending_exception(); 10745 heap->isolate()->clear_pending_exception();
10688 if (caught_exception != NULL) { 10746 if (caught_exception != NULL) *caught_exception = true;
10689 *caught_exception = true; 10747 return exception;
10690 }
10691 return maybe_value;
10692 } 10748 }
10693 return value; 10749 return *value;
10694 } else { 10750 } else {
10695 return heap->undefined_value(); 10751 return heap->undefined_value();
10696 } 10752 }
10697 } 10753 }
10698 case INTERCEPTOR: 10754 case INTERCEPTOR:
10699 case TRANSITION: 10755 case TRANSITION:
10700 return heap->undefined_value(); 10756 return heap->undefined_value();
10701 case HANDLER: 10757 case HANDLER:
10702 case NONEXISTENT: 10758 case NONEXISTENT:
10703 UNREACHABLE(); 10759 UNREACHABLE();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
10871 // args[0]: object 10927 // args[0]: object
10872 // args[1]: property name 10928 // args[1]: property name
10873 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { 10929 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) {
10874 HandleScope scope(isolate); 10930 HandleScope scope(isolate);
10875 ASSERT(args.length() == 2); 10931 ASSERT(args.length() == 2);
10876 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 10932 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10877 RUNTIME_ASSERT(obj->HasNamedInterceptor()); 10933 RUNTIME_ASSERT(obj->HasNamedInterceptor());
10878 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 10934 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
10879 10935
10880 PropertyAttributes attributes; 10936 PropertyAttributes attributes;
10881 return obj->GetPropertyWithInterceptor(*obj, *name, &attributes); 10937 Handle<Object> result =
10938 JSObject::GetPropertyWithInterceptor(obj, obj, name, &attributes);
10939 RETURN_IF_EMPTY_HANDLE(isolate, result);
10940 return *result;
10882 } 10941 }
10883 10942
10884 10943
10885 // Return element value from indexed interceptor. 10944 // Return element value from indexed interceptor.
10886 // args[0]: object 10945 // args[0]: object
10887 // args[1]: index 10946 // args[1]: index
10888 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { 10947 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) {
10889 HandleScope scope(isolate); 10948 HandleScope scope(isolate);
10890 ASSERT(args.length() == 2); 10949 ASSERT(args.length() == 2);
10891 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 10950 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
12603 // Get the step action and check validity. 12662 // Get the step action and check validity.
12604 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); 12663 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1]));
12605 if (step_action != StepIn && 12664 if (step_action != StepIn &&
12606 step_action != StepNext && 12665 step_action != StepNext &&
12607 step_action != StepOut && 12666 step_action != StepOut &&
12608 step_action != StepInMin && 12667 step_action != StepInMin &&
12609 step_action != StepMin) { 12668 step_action != StepMin) {
12610 return isolate->Throw(isolate->heap()->illegal_argument_string()); 12669 return isolate->Throw(isolate->heap()->illegal_argument_string());
12611 } 12670 }
12612 12671
12613 if (frame_id != StackFrame::NO_ID && 12672 if (frame_id != StackFrame::NO_ID && step_action != StepNext &&
12614 step_action != StepIn && 12673 step_action != StepMin && step_action != StepOut) {
12615 step_action != StepNext &&
12616 step_action != StepOut &&
12617 step_action != StepMin) {
12618 return isolate->ThrowIllegalOperation(); 12674 return isolate->ThrowIllegalOperation();
12619 } 12675 }
12620 12676
12621 // Get the number of steps. 12677 // Get the number of steps.
12622 int step_count = NumberToInt32(args[2]); 12678 int step_count = NumberToInt32(args[2]);
12623 if (step_count < 1) { 12679 if (step_count < 1) {
12624 return isolate->Throw(isolate->heap()->illegal_argument_string()); 12680 return isolate->Throw(isolate->heap()->illegal_argument_string());
12625 } 12681 }
12626 12682
12627 // Clear all current stepping setup. 12683 // Clear all current stepping setup.
(...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after
14534 Object* proto = obj->GetPrototype(); 14590 Object* proto = obj->GetPrototype();
14535 if (proto->IsNull()) return isolate->heap()->false_value(); 14591 if (proto->IsNull()) return isolate->heap()->false_value();
14536 ASSERT(proto->IsJSGlobalObject()); 14592 ASSERT(proto->IsJSGlobalObject());
14537 obj = JSReceiver::cast(proto); 14593 obj = JSReceiver::cast(proto);
14538 } 14594 }
14539 return isolate->heap()->ToBoolean(obj->map()->is_observed()); 14595 return isolate->heap()->ToBoolean(obj->map()->is_observed());
14540 } 14596 }
14541 14597
14542 14598
14543 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { 14599 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) {
14544 SealHandleScope shs(isolate); 14600 HandleScope scope(isolate);
14545 ASSERT(args.length() == 1); 14601 ASSERT(args.length() == 1);
14546 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); 14602 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
14547 if (obj->IsJSGlobalProxy()) { 14603 if (obj->IsJSGlobalProxy()) {
14548 Object* proto = obj->GetPrototype(); 14604 Object* proto = obj->GetPrototype();
14549 if (proto->IsNull()) return isolate->heap()->undefined_value(); 14605 if (proto->IsNull()) return isolate->heap()->undefined_value();
14550 ASSERT(proto->IsJSGlobalObject()); 14606 ASSERT(proto->IsJSGlobalObject());
14551 obj = JSReceiver::cast(proto); 14607 obj = handle(JSReceiver::cast(proto));
14552 } 14608 }
14553 if (obj->IsJSProxy()) 14609 if (obj->IsJSProxy())
14554 return isolate->heap()->undefined_value(); 14610 return isolate->heap()->undefined_value();
14555 14611
14556 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && 14612 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() &&
14557 JSObject::cast(obj)->HasFastElements())); 14613 Handle<JSObject>::cast(obj)->HasFastElements()));
14558 ASSERT(obj->IsJSObject()); 14614 ASSERT(obj->IsJSObject());
14559 return JSObject::cast(obj)->SetObserved(isolate); 14615 JSObject::SetObserved(Handle<JSObject>::cast(obj));
14616 return isolate->heap()->undefined_value();
14560 } 14617 }
14561 14618
14562 14619
14563 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { 14620 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) {
14564 SealHandleScope shs(isolate); 14621 SealHandleScope shs(isolate);
14565 ASSERT(args.length() == 0); 14622 ASSERT(args.length() == 0);
14566 isolate->set_observer_delivery_pending(true); 14623 isolate->set_observer_delivery_pending(true);
14567 return isolate->heap()->undefined_value(); 14624 return isolate->heap()->undefined_value();
14568 } 14625 }
14569 14626
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
14653 14710
14654 JSArray* array; 14711 JSArray* array;
14655 MaybeObject* maybe_array; 14712 MaybeObject* maybe_array;
14656 if (!type_info.is_null() && 14713 if (!type_info.is_null() &&
14657 *type_info != isolate->heap()->undefined_value() && 14714 *type_info != isolate->heap()->undefined_value() &&
14658 Cell::cast(*type_info)->value()->IsAllocationSite() && 14715 Cell::cast(*type_info)->value()->IsAllocationSite() &&
14659 can_use_type_feedback) { 14716 can_use_type_feedback) {
14660 Handle<Cell> cell = Handle<Cell>::cast(type_info); 14717 Handle<Cell> cell = Handle<Cell>::cast(type_info);
14661 Handle<AllocationSite> site = Handle<AllocationSite>( 14718 Handle<AllocationSite> site = Handle<AllocationSite>(
14662 AllocationSite::cast(cell->value()), isolate); 14719 AllocationSite::cast(cell->value()), isolate);
14663 ASSERT(!site->IsLiteralSite()); 14720 ASSERT(!site->SitePointsToLiteral());
14664 ElementsKind to_kind = site->GetElementsKind(); 14721 ElementsKind to_kind = site->GetElementsKind();
14665 if (holey && !IsFastHoleyElementsKind(to_kind)) { 14722 if (holey && !IsFastHoleyElementsKind(to_kind)) {
14666 to_kind = GetHoleyElementsKind(to_kind); 14723 to_kind = GetHoleyElementsKind(to_kind);
14667 // Update the allocation site info to reflect the advice alteration. 14724 // Update the allocation site info to reflect the advice alteration.
14668 site->SetElementsKind(to_kind); 14725 site->SetElementsKind(to_kind);
14669 } 14726 }
14670 14727
14671 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( 14728 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite(
14672 *constructor, site); 14729 *constructor, site);
14673 if (!maybe_array->To(&array)) return maybe_array; 14730 if (!maybe_array->To(&array)) return maybe_array;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
14809 // Handle last resort GC and make sure to allow future allocations 14866 // Handle last resort GC and make sure to allow future allocations
14810 // to grow the heap without causing GCs (if possible). 14867 // to grow the heap without causing GCs (if possible).
14811 isolate->counters()->gc_last_resort_from_js()->Increment(); 14868 isolate->counters()->gc_last_resort_from_js()->Increment();
14812 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14869 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14813 "Runtime::PerformGC"); 14870 "Runtime::PerformGC");
14814 } 14871 }
14815 } 14872 }
14816 14873
14817 14874
14818 } } // namespace v8::internal 14875 } } // 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