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

Side by Side Diff: src/runtime.cc

Issue 39973003: Merge bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: again Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | 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 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2901 } 2926 }
2902 2927
2903 // 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
2904 // shared unoptimized code makes them impossible to enqueue in a list. 2929 // shared unoptimized code makes them impossible to enqueue in a list.
2905 ASSERT(target_shared->code()->gc_metadata() == NULL); 2930 ASSERT(target_shared->code()->gc_metadata() == NULL);
2906 ASSERT(source_shared->code()->gc_metadata() == NULL); 2931 ASSERT(source_shared->code()->gc_metadata() == NULL);
2907 target_shared->set_dont_flush(true); 2932 target_shared->set_dont_flush(true);
2908 source_shared->set_dont_flush(true); 2933 source_shared->set_dont_flush(true);
2909 2934
2910 // Set the code, scope info, formal parameter count, and the length 2935 // Set the code, scope info, formal parameter count, and the length
2911 // of the target shared function info. Set the source code of the 2936 // of the target shared function info.
2912 // target function to undefined. SetCode is only used for built-in
2913 // constructors like String, Array, and Object, and some web code
2914 // doesn't like seeing source code for constructors.
2915 target_shared->ReplaceCode(source_shared->code()); 2937 target_shared->ReplaceCode(source_shared->code());
2916 target_shared->set_scope_info(source_shared->scope_info()); 2938 target_shared->set_scope_info(source_shared->scope_info());
2917 target_shared->set_length(source_shared->length()); 2939 target_shared->set_length(source_shared->length());
2918 target_shared->set_formal_parameter_count( 2940 target_shared->set_formal_parameter_count(
2919 source_shared->formal_parameter_count()); 2941 source_shared->formal_parameter_count());
2920 target_shared->set_script(isolate->heap()->undefined_value()); 2942 target_shared->set_script(source_shared->script());
2921 2943 target_shared->set_start_position_and_type(
2922 // Since we don't store the source we should never optimize this. 2944 source_shared->start_position_and_type());
2923 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);
2924 2949
2925 // Set the code of the target function. 2950 // Set the code of the target function.
2926 target->ReplaceCode(source_shared->code()); 2951 target->ReplaceCode(source_shared->code());
2927 ASSERT(target->next_function_link()->IsUndefined()); 2952 ASSERT(target->next_function_link()->IsUndefined());
2928 2953
2929 // 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
2930 // context contamination. 2955 // context contamination.
2931 Handle<Context> context(source->context()); 2956 Handle<Context> context(source->context());
2932 int number_of_literals = source->NumberOfLiterals(); 2957 int number_of_literals = source->NumberOfLiterals();
2933 Handle<FixedArray> literals = 2958 Handle<FixedArray> literals =
(...skipping 11 matching lines...) Expand all
2945 source_shared, Handle<Code>(source_shared->code())); 2970 source_shared, Handle<Code>(source_shared->code()));
2946 } 2971 }
2947 2972
2948 return *target; 2973 return *target;
2949 } 2974 }
2950 2975
2951 2976
2952 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { 2977 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) {
2953 HandleScope scope(isolate); 2978 HandleScope scope(isolate);
2954 ASSERT(args.length() == 2); 2979 ASSERT(args.length() == 2);
2955 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 2980 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
2956 CONVERT_SMI_ARG_CHECKED(num, 1); 2981 CONVERT_SMI_ARG_CHECKED(num, 1);
2957 RUNTIME_ASSERT(num >= 0); 2982 RUNTIME_ASSERT(num >= 0);
2958 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 }
2959 return isolate->heap()->undefined_value(); 2998 return isolate->heap()->undefined_value();
2960 } 2999 }
2961 3000
2962 3001
2963 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) { 3002 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) {
2964 SealHandleScope shs(isolate); 3003 SealHandleScope shs(isolate);
2965 ASSERT(args.length() == 0); 3004 ASSERT(args.length() == 0);
2966 3005
2967 JavaScriptFrameIterator it(isolate); 3006 JavaScriptFrameIterator it(isolate);
2968 JavaScriptFrame* frame = it.frame(); 3007 JavaScriptFrame* frame = it.frame();
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after
5536 return HasLocalPropertyImplementation(isolate, 5575 return HasLocalPropertyImplementation(isolate,
5537 Handle<JSObject>::cast(proto), 5576 Handle<JSObject>::cast(proto),
5538 key); 5577 key);
5539 } 5578 }
5540 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5579 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5541 return isolate->heap()->false_value(); 5580 return isolate->heap()->false_value();
5542 } 5581 }
5543 5582
5544 5583
5545 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { 5584 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
5546 SealHandleScope shs(isolate); 5585 HandleScope scope(isolate);
5547 ASSERT(args.length() == 2); 5586 ASSERT(args.length() == 2);
5548 CONVERT_ARG_CHECKED(Name, key, 1); 5587 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5588 Handle<Object> object = args.at<Object>(0);
5549 5589
5550 uint32_t index; 5590 uint32_t index;
5551 const bool key_is_array_index = key->AsArrayIndex(&index); 5591 const bool key_is_array_index = key->AsArrayIndex(&index);
5552 5592
5553 Object* obj = args[0];
5554 // Only JS objects can have properties. 5593 // Only JS objects can have properties.
5555 if (obj->IsJSObject()) { 5594 if (object->IsJSObject()) {
5556 JSObject* object = JSObject::cast(obj); 5595 Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
5557 // 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
5558 // an array index and there are no interceptors or hidden 5597 // an array index and there are no interceptors or hidden
5559 // prototypes. 5598 // prototypes.
5560 if (object->HasRealNamedProperty(isolate, key)) { 5599 if (JSObject::HasRealNamedProperty(js_obj, key)) {
5561 ASSERT(!isolate->has_scheduled_exception()); 5600 ASSERT(!isolate->has_scheduled_exception());
5562 return isolate->heap()->true_value(); 5601 return isolate->heap()->true_value();
5563 } else { 5602 } else {
5564 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5603 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5565 } 5604 }
5566 Map* map = object->map(); 5605 Map* map = js_obj->map();
5567 if (!key_is_array_index && 5606 if (!key_is_array_index &&
5568 !map->has_named_interceptor() && 5607 !map->has_named_interceptor() &&
5569 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { 5608 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) {
5570 return isolate->heap()->false_value(); 5609 return isolate->heap()->false_value();
5571 } 5610 }
5572 // Slow case. 5611 // Slow case.
5573 HandleScope scope(isolate);
5574 return HasLocalPropertyImplementation(isolate, 5612 return HasLocalPropertyImplementation(isolate,
5575 Handle<JSObject>(object), 5613 Handle<JSObject>(js_obj),
5576 Handle<Name>(key)); 5614 Handle<Name>(key));
5577 } else if (obj->IsString() && key_is_array_index) { 5615 } else if (object->IsString() && key_is_array_index) {
5578 // Well, there is one exception: Handle [] on strings. 5616 // Well, there is one exception: Handle [] on strings.
5579 String* string = String::cast(obj); 5617 Handle<String> string = Handle<String>::cast(object);
5580 if (index < static_cast<uint32_t>(string->length())) { 5618 if (index < static_cast<uint32_t>(string->length())) {
5581 return isolate->heap()->true_value(); 5619 return isolate->heap()->true_value();
5582 } 5620 }
5583 } 5621 }
5584 return isolate->heap()->false_value(); 5622 return isolate->heap()->false_value();
5585 } 5623 }
5586 5624
5587 5625
5588 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { 5626 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
5589 HandleScope scope(isolate); 5627 HandleScope scope(isolate);
(...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after
8301 8339
8302 8340
8303 bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) { 8341 bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) {
8304 // If the function is not compiled ignore the lazy 8342 // If the function is not compiled ignore the lazy
8305 // recompilation. This can happen if the debugger is activated and 8343 // recompilation. This can happen if the debugger is activated and
8306 // the function is returned to the not compiled state. 8344 // the function is returned to the not compiled state.
8307 if (!function->shared()->is_compiled()) return false; 8345 if (!function->shared()->is_compiled()) return false;
8308 8346
8309 // 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
8310 // code from the full compiler. 8348 // code from the full compiler.
8311 if (!FLAG_crankshaft || 8349 if (!isolate->use_crankshaft() ||
8312 function->shared()->optimization_disabled() || 8350 function->shared()->optimization_disabled() ||
8313 isolate->DebuggerHasBreakPoints()) { 8351 isolate->DebuggerHasBreakPoints()) {
8314 if (FLAG_trace_opt) { 8352 if (FLAG_trace_opt) {
8315 PrintF("[failed to optimize "); 8353 PrintF("[failed to optimize ");
8316 function->PrintName(); 8354 function->PrintName();
8317 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", 8355 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n",
8318 function->shared()->optimization_disabled() ? "F" : "T", 8356 function->shared()->optimization_disabled() ? "F" : "T",
8319 isolate->DebuggerHasBreakPoints() ? "T" : "F"); 8357 isolate->DebuggerHasBreakPoints() ? "T" : "F");
8320 } 8358 }
8321 return false; 8359 return false;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
8564 : Smi::FromInt(2); // 2 == "no". 8602 : Smi::FromInt(2); // 2 == "no".
8565 } 8603 }
8566 if (FLAG_deopt_every_n_times) { 8604 if (FLAG_deopt_every_n_times) {
8567 return Smi::FromInt(6); // 6 == "maybe deopted". 8605 return Smi::FromInt(6); // 6 == "maybe deopted".
8568 } 8606 }
8569 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". 8607 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes".
8570 : Smi::FromInt(2); // 2 == "no". 8608 : Smi::FromInt(2); // 2 == "no".
8571 } 8609 }
8572 8610
8573 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
8574 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { 8619 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) {
8575 HandleScope scope(isolate); 8620 HandleScope scope(isolate);
8576 ASSERT(args.length() == 1); 8621 ASSERT(args.length() == 1);
8577 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8622 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8578 return Smi::FromInt(function->shared()->opt_count()); 8623 return Smi::FromInt(function->shared()->opt_count());
8579 } 8624 }
8580 8625
8581 8626
8582 static bool IsSuitableForOnStackReplacement(Isolate* isolate, 8627 static bool IsSuitableForOnStackReplacement(Isolate* isolate,
8583 Handle<JSFunction> function, 8628 Handle<JSFunction> function,
8584 Handle<Code> unoptimized) { 8629 Handle<Code> unoptimized) {
8585 // Keep track of whether we've succeeded in optimizing. 8630 // Keep track of whether we've succeeded in optimizing.
8586 if (!unoptimized->optimizable()) return false; 8631 if (!isolate->use_crankshaft() || !unoptimized->optimizable()) return false;
8587 // 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
8588 // 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
8589 // indirectly recursive and (b) an optimized invocation has been 8634 // indirectly recursive and (b) an optimized invocation has been
8590 // deoptimized so that we are currently in an unoptimized activation. 8635 // deoptimized so that we are currently in an unoptimized activation.
8591 // Check for optimized activations of this function. 8636 // Check for optimized activations of this function.
8592 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { 8637 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
8593 JavaScriptFrame* frame = it.frame(); 8638 JavaScriptFrame* frame = it.frame();
8594 if (frame->is_optimized() && frame->function() == *function) return false; 8639 if (frame->is_optimized() && frame->function() == *function) return false;
8595 } 8640 }
8596 8641
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after
10681 if (value->IsTheHole()) { 10726 if (value->IsTheHole()) {
10682 return heap->undefined_value(); 10727 return heap->undefined_value();
10683 } 10728 }
10684 return value; 10729 return value;
10685 } 10730 }
10686 case CONSTANT: 10731 case CONSTANT:
10687 return result->GetConstant(); 10732 return result->GetConstant();
10688 case CALLBACKS: { 10733 case CALLBACKS: {
10689 Object* structure = result->GetCallbackObject(); 10734 Object* structure = result->GetCallbackObject();
10690 if (structure->IsForeign() || structure->IsAccessorInfo()) { 10735 if (structure->IsForeign() || structure->IsAccessorInfo()) {
10691 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( 10736 Isolate* isolate = heap->isolate();
10692 receiver, structure, name); 10737 HandleScope scope(isolate);
10693 if (!maybe_value->ToObject(&value)) { 10738 Handle<Object> value = JSObject::GetPropertyWithCallback(
10694 if (maybe_value->IsRetryAfterGC()) return maybe_value; 10739 handle(result->holder(), isolate),
10695 ASSERT(maybe_value->IsException()); 10740 handle(receiver, isolate),
10696 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();
10697 heap->isolate()->clear_pending_exception(); 10745 heap->isolate()->clear_pending_exception();
10698 if (caught_exception != NULL) { 10746 if (caught_exception != NULL) *caught_exception = true;
10699 *caught_exception = true; 10747 return exception;
10700 }
10701 return maybe_value;
10702 } 10748 }
10703 return value; 10749 return *value;
10704 } else { 10750 } else {
10705 return heap->undefined_value(); 10751 return heap->undefined_value();
10706 } 10752 }
10707 } 10753 }
10708 case INTERCEPTOR: 10754 case INTERCEPTOR:
10709 case TRANSITION: 10755 case TRANSITION:
10710 return heap->undefined_value(); 10756 return heap->undefined_value();
10711 case HANDLER: 10757 case HANDLER:
10712 case NONEXISTENT: 10758 case NONEXISTENT:
10713 UNREACHABLE(); 10759 UNREACHABLE();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
10881 // args[0]: object 10927 // args[0]: object
10882 // args[1]: property name 10928 // args[1]: property name
10883 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { 10929 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) {
10884 HandleScope scope(isolate); 10930 HandleScope scope(isolate);
10885 ASSERT(args.length() == 2); 10931 ASSERT(args.length() == 2);
10886 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 10932 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
10887 RUNTIME_ASSERT(obj->HasNamedInterceptor()); 10933 RUNTIME_ASSERT(obj->HasNamedInterceptor());
10888 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 10934 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
10889 10935
10890 PropertyAttributes attributes; 10936 PropertyAttributes attributes;
10891 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;
10892 } 10941 }
10893 10942
10894 10943
10895 // Return element value from indexed interceptor. 10944 // Return element value from indexed interceptor.
10896 // args[0]: object 10945 // args[0]: object
10897 // args[1]: index 10946 // args[1]: index
10898 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { 10947 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) {
10899 HandleScope scope(isolate); 10948 HandleScope scope(isolate);
10900 ASSERT(args.length() == 2); 10949 ASSERT(args.length() == 2);
10901 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 10950 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
(...skipping 3639 matching lines...) Expand 10 before | Expand all | Expand 10 after
14541 Object* proto = obj->GetPrototype(); 14590 Object* proto = obj->GetPrototype();
14542 if (proto->IsNull()) return isolate->heap()->false_value(); 14591 if (proto->IsNull()) return isolate->heap()->false_value();
14543 ASSERT(proto->IsJSGlobalObject()); 14592 ASSERT(proto->IsJSGlobalObject());
14544 obj = JSReceiver::cast(proto); 14593 obj = JSReceiver::cast(proto);
14545 } 14594 }
14546 return isolate->heap()->ToBoolean(obj->map()->is_observed()); 14595 return isolate->heap()->ToBoolean(obj->map()->is_observed());
14547 } 14596 }
14548 14597
14549 14598
14550 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { 14599 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) {
14551 SealHandleScope shs(isolate); 14600 HandleScope scope(isolate);
14552 ASSERT(args.length() == 1); 14601 ASSERT(args.length() == 1);
14553 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); 14602 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
14554 if (obj->IsJSGlobalProxy()) { 14603 if (obj->IsJSGlobalProxy()) {
14555 Object* proto = obj->GetPrototype(); 14604 Object* proto = obj->GetPrototype();
14556 if (proto->IsNull()) return isolate->heap()->undefined_value(); 14605 if (proto->IsNull()) return isolate->heap()->undefined_value();
14557 ASSERT(proto->IsJSGlobalObject()); 14606 ASSERT(proto->IsJSGlobalObject());
14558 obj = JSReceiver::cast(proto); 14607 obj = handle(JSReceiver::cast(proto));
14559 } 14608 }
14560 if (obj->IsJSProxy()) 14609 if (obj->IsJSProxy())
14561 return isolate->heap()->undefined_value(); 14610 return isolate->heap()->undefined_value();
14562 14611
14563 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() && 14612 ASSERT(!(obj->map()->is_observed() && obj->IsJSObject() &&
14564 JSObject::cast(obj)->HasFastElements())); 14613 Handle<JSObject>::cast(obj)->HasFastElements()));
14565 ASSERT(obj->IsJSObject()); 14614 ASSERT(obj->IsJSObject());
14566 return JSObject::cast(obj)->SetObserved(isolate); 14615 JSObject::SetObserved(Handle<JSObject>::cast(obj));
14616 return isolate->heap()->undefined_value();
14567 } 14617 }
14568 14618
14569 14619
14570 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) { 14620 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetObserverDeliveryPending) {
14571 SealHandleScope shs(isolate); 14621 SealHandleScope shs(isolate);
14572 ASSERT(args.length() == 0); 14622 ASSERT(args.length() == 0);
14573 isolate->set_observer_delivery_pending(true); 14623 isolate->set_observer_delivery_pending(true);
14574 return isolate->heap()->undefined_value(); 14624 return isolate->heap()->undefined_value();
14575 } 14625 }
14576 14626
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
14660 14710
14661 JSArray* array; 14711 JSArray* array;
14662 MaybeObject* maybe_array; 14712 MaybeObject* maybe_array;
14663 if (!type_info.is_null() && 14713 if (!type_info.is_null() &&
14664 *type_info != isolate->heap()->undefined_value() && 14714 *type_info != isolate->heap()->undefined_value() &&
14665 Cell::cast(*type_info)->value()->IsAllocationSite() && 14715 Cell::cast(*type_info)->value()->IsAllocationSite() &&
14666 can_use_type_feedback) { 14716 can_use_type_feedback) {
14667 Handle<Cell> cell = Handle<Cell>::cast(type_info); 14717 Handle<Cell> cell = Handle<Cell>::cast(type_info);
14668 Handle<AllocationSite> site = Handle<AllocationSite>( 14718 Handle<AllocationSite> site = Handle<AllocationSite>(
14669 AllocationSite::cast(cell->value()), isolate); 14719 AllocationSite::cast(cell->value()), isolate);
14670 ASSERT(!site->IsLiteralSite()); 14720 ASSERT(!site->SitePointsToLiteral());
14671 ElementsKind to_kind = site->GetElementsKind(); 14721 ElementsKind to_kind = site->GetElementsKind();
14672 if (holey && !IsFastHoleyElementsKind(to_kind)) { 14722 if (holey && !IsFastHoleyElementsKind(to_kind)) {
14673 to_kind = GetHoleyElementsKind(to_kind); 14723 to_kind = GetHoleyElementsKind(to_kind);
14674 // Update the allocation site info to reflect the advice alteration. 14724 // Update the allocation site info to reflect the advice alteration.
14675 site->SetElementsKind(to_kind); 14725 site->SetElementsKind(to_kind);
14676 } 14726 }
14677 14727
14678 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( 14728 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite(
14679 *constructor, site); 14729 *constructor, site);
14680 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
14816 // Handle last resort GC and make sure to allow future allocations 14866 // Handle last resort GC and make sure to allow future allocations
14817 // to grow the heap without causing GCs (if possible). 14867 // to grow the heap without causing GCs (if possible).
14818 isolate->counters()->gc_last_resort_from_js()->Increment(); 14868 isolate->counters()->gc_last_resort_from_js()->Increment();
14819 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14869 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14820 "Runtime::PerformGC"); 14870 "Runtime::PerformGC");
14821 } 14871 }
14822 } 14872 }
14823 14873
14824 14874
14825 } } // 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