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

Side by Side Diff: src/isolate.cc

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/isolate.h ('k') | src/json.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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 Handle<Object> caller, 447 Handle<Object> caller,
448 int limit) { 448 int limit) {
449 limit = Max(limit, 0); // Ensure that limit is not negative. 449 limit = Max(limit, 0); // Ensure that limit is not negative.
450 int initial_size = Min(limit, 10); 450 int initial_size = Min(limit, 10);
451 Handle<FixedArray> elements = 451 Handle<FixedArray> elements =
452 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1); 452 factory()->NewFixedArrayWithHoles(initial_size * 4 + 1);
453 453
454 // If the caller parameter is a function we skip frames until we're 454 // If the caller parameter is a function we skip frames until we're
455 // under it before starting to collect. 455 // under it before starting to collect.
456 bool seen_caller = !caller->IsJSFunction(); 456 bool seen_caller = !caller->IsJSFunction();
457 // First element is reserved to store the number of non-strict frames. 457 // First element is reserved to store the number of sloppy frames.
458 int cursor = 1; 458 int cursor = 1;
459 int frames_seen = 0; 459 int frames_seen = 0;
460 int non_strict_frames = 0; 460 int sloppy_frames = 0;
461 bool encountered_strict_function = false; 461 bool encountered_strict_function = false;
462 for (StackFrameIterator iter(this); 462 for (StackFrameIterator iter(this);
463 !iter.done() && frames_seen < limit; 463 !iter.done() && frames_seen < limit;
464 iter.Advance()) { 464 iter.Advance()) {
465 StackFrame* raw_frame = iter.frame(); 465 StackFrame* raw_frame = iter.frame();
466 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) { 466 if (IsVisibleInStackTrace(raw_frame, *caller, &seen_caller)) {
467 frames_seen++; 467 frames_seen++;
468 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame); 468 JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame);
469 // Set initial size to the maximum inlining level + 1 for the outermost 469 // Set initial size to the maximum inlining level + 1 for the outermost
470 // function. 470 // function.
(...skipping 10 matching lines...) Expand all
481 elements = new_elements; 481 elements = new_elements;
482 } 482 }
483 ASSERT(cursor + 4 <= elements->length()); 483 ASSERT(cursor + 4 <= elements->length());
484 484
485 Handle<Object> recv = frames[i].receiver(); 485 Handle<Object> recv = frames[i].receiver();
486 Handle<JSFunction> fun = frames[i].function(); 486 Handle<JSFunction> fun = frames[i].function();
487 Handle<Code> code = frames[i].code(); 487 Handle<Code> code = frames[i].code();
488 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this); 488 Handle<Smi> offset(Smi::FromInt(frames[i].offset()), this);
489 // The stack trace API should not expose receivers and function 489 // The stack trace API should not expose receivers and function
490 // objects on frames deeper than the top-most one with a strict 490 // objects on frames deeper than the top-most one with a strict
491 // mode function. The number of non-strict frames is stored as 491 // mode function. The number of sloppy frames is stored as
492 // first element in the result array. 492 // first element in the result array.
493 if (!encountered_strict_function) { 493 if (!encountered_strict_function) {
494 if (!fun->shared()->is_classic_mode()) { 494 if (fun->shared()->strict_mode() == STRICT) {
495 encountered_strict_function = true; 495 encountered_strict_function = true;
496 } else { 496 } else {
497 non_strict_frames++; 497 sloppy_frames++;
498 } 498 }
499 } 499 }
500 elements->set(cursor++, *recv); 500 elements->set(cursor++, *recv);
501 elements->set(cursor++, *fun); 501 elements->set(cursor++, *fun);
502 elements->set(cursor++, *code); 502 elements->set(cursor++, *code);
503 elements->set(cursor++, *offset); 503 elements->set(cursor++, *offset);
504 } 504 }
505 } 505 }
506 } 506 }
507 elements->set(0, Smi::FromInt(non_strict_frames)); 507 elements->set(0, Smi::FromInt(sloppy_frames));
508 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements); 508 Handle<JSArray> result = factory()->NewJSArrayWithElements(elements);
509 result->set_length(Smi::FromInt(cursor)); 509 result->set_length(Smi::FromInt(cursor));
510 return result; 510 return result;
511 } 511 }
512 512
513 513
514 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) { 514 void Isolate::CaptureAndSetDetailedStackTrace(Handle<JSObject> error_object) {
515 if (capture_stack_trace_for_uncaught_exceptions_) { 515 if (capture_stack_trace_for_uncaught_exceptions_) {
516 // Capture stack trace for a detailed exception message. 516 // Capture stack trace for a detailed exception message.
517 Handle<String> key = factory()->hidden_stack_trace_string(); 517 Handle<String> key = factory()->hidden_stack_trace_string();
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 native_context->security_token()) 772 native_context->security_token())
773 return YES; 773 return YES;
774 } 774 }
775 775
776 return UNKNOWN; 776 return UNKNOWN;
777 } 777 }
778 778
779 779
780 bool Isolate::MayNamedAccess(JSObject* receiver, Object* key, 780 bool Isolate::MayNamedAccess(JSObject* receiver, Object* key,
781 v8::AccessType type) { 781 v8::AccessType type) {
782 ASSERT(receiver->IsAccessCheckNeeded()); 782 ASSERT(receiver->IsJSGlobalProxy() || receiver->IsAccessCheckNeeded());
783 783
784 // The callers of this method are not expecting a GC. 784 // The callers of this method are not expecting a GC.
785 DisallowHeapAllocation no_gc; 785 DisallowHeapAllocation no_gc;
786 786
787 // Skip checks for hidden properties access. Note, we do not 787 // Skip checks for hidden properties access. Note, we do not
788 // require existence of a context in this case. 788 // require existence of a context in this case.
789 if (key == heap_.hidden_string()) return true; 789 if (key == heap_.hidden_string()) return true;
790 790
791 // Check for compatibility between the security tokens in the 791 // Check for compatibility between the security tokens in the
792 // current lexical context and the accessed object. 792 // current lexical context and the accessed object.
(...skipping 30 matching lines...) Expand all
823 type, 823 type,
824 v8::Utils::ToLocal(data)); 824 v8::Utils::ToLocal(data));
825 } 825 }
826 return result; 826 return result;
827 } 827 }
828 828
829 829
830 bool Isolate::MayIndexedAccess(JSObject* receiver, 830 bool Isolate::MayIndexedAccess(JSObject* receiver,
831 uint32_t index, 831 uint32_t index,
832 v8::AccessType type) { 832 v8::AccessType type) {
833 ASSERT(receiver->IsAccessCheckNeeded()); 833 ASSERT(receiver->IsJSGlobalProxy() || receiver->IsAccessCheckNeeded());
834 // Check for compatibility between the security tokens in the 834 // Check for compatibility between the security tokens in the
835 // current lexical context and the accessed object. 835 // current lexical context and the accessed object.
836 ASSERT(context()); 836 ASSERT(context());
837 837
838 MayAccessDecision decision = MayAccessPreCheck(this, receiver, type); 838 MayAccessDecision decision = MayAccessPreCheck(this, receiver, type);
839 if (decision != UNKNOWN) return decision == YES; 839 if (decision != UNKNOWN) return decision == YES;
840 840
841 // Get indexed access check callback 841 // Get indexed access check callback
842 JSFunction* constructor = JSFunction::cast(receiver->map()->constructor()); 842 JSFunction* constructor = JSFunction::cast(receiver->map()->constructor());
843 if (!constructor->shared()->IsApiFunction()) return false; 843 if (!constructor->shared()->IsApiFunction()) return false;
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 context_slot_cache_(NULL), 1544 context_slot_cache_(NULL),
1545 descriptor_lookup_cache_(NULL), 1545 descriptor_lookup_cache_(NULL),
1546 handle_scope_implementer_(NULL), 1546 handle_scope_implementer_(NULL),
1547 unicode_cache_(NULL), 1547 unicode_cache_(NULL),
1548 runtime_zone_(this), 1548 runtime_zone_(this),
1549 inner_pointer_to_code_cache_(NULL), 1549 inner_pointer_to_code_cache_(NULL),
1550 write_iterator_(NULL), 1550 write_iterator_(NULL),
1551 global_handles_(NULL), 1551 global_handles_(NULL),
1552 eternal_handles_(NULL), 1552 eternal_handles_(NULL),
1553 thread_manager_(NULL), 1553 thread_manager_(NULL),
1554 fp_stubs_generated_(false),
1555 has_installed_extensions_(false), 1554 has_installed_extensions_(false),
1556 string_tracker_(NULL), 1555 string_tracker_(NULL),
1557 regexp_stack_(NULL), 1556 regexp_stack_(NULL),
1558 date_cache_(NULL), 1557 date_cache_(NULL),
1559 code_stub_interface_descriptors_(NULL), 1558 code_stub_interface_descriptors_(NULL),
1560 call_descriptors_(NULL), 1559 call_descriptors_(NULL),
1561 // TODO(bmeurer) Initialized lazily because it depends on flags; can 1560 // TODO(bmeurer) Initialized lazily because it depends on flags; can
1562 // be fixed once the default isolate cleanup is done. 1561 // be fixed once the default isolate cleanup is done.
1563 random_number_generator_(NULL), 1562 random_number_generator_(NULL),
1564 has_fatal_error_(false), 1563 has_fatal_error_(false),
1565 use_crankshaft_(true), 1564 use_crankshaft_(true),
1566 initialized_from_snapshot_(false), 1565 initialized_from_snapshot_(false),
1567 cpu_profiler_(NULL), 1566 cpu_profiler_(NULL),
1568 heap_profiler_(NULL), 1567 heap_profiler_(NULL),
1569 function_entry_hook_(NULL), 1568 function_entry_hook_(NULL),
1570 deferred_handles_head_(NULL), 1569 deferred_handles_head_(NULL),
1571 optimizing_compiler_thread_(NULL), 1570 optimizing_compiler_thread_(NULL),
1572 sweeper_thread_(NULL), 1571 sweeper_thread_(NULL),
1573 num_sweeper_threads_(0), 1572 num_sweeper_threads_(0),
1574 max_available_threads_(0),
1575 stress_deopt_count_(0), 1573 stress_deopt_count_(0),
1576 lexer_gc_handler_(0), 1574 lexer_gc_handler_(0),
1577 next_optimization_id_(0) { 1575 next_optimization_id_(0) {
1578 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); 1576 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1);
1579 TRACE_ISOLATE(constructor); 1577 TRACE_ISOLATE(constructor);
1580 1578
1581 memset(isolate_addresses_, 0, 1579 memset(isolate_addresses_, 0,
1582 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); 1580 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1));
1583 1581
1584 heap_.isolate_ = this; 1582 heap_.isolate_ = this;
1585 stack_guard_.isolate_ = this; 1583 stack_guard_.isolate_ = this;
1586 1584
1587 // ThreadManager is initialized early to support locking an isolate 1585 // ThreadManager is initialized early to support locking an isolate
1588 // before it is entered. 1586 // before it is entered.
1589 thread_manager_ = new ThreadManager(); 1587 thread_manager_ = new ThreadManager();
1590 thread_manager_->isolate_ = this; 1588 thread_manager_->isolate_ = this;
1591 1589
1592 #if V8_TARGET_ARCH_ARM && !defined(__arm__) || \
1593 V8_TARGET_ARCH_A64 && !defined(__aarch64__) || \
1594 V8_TARGET_ARCH_MIPS && !defined(__mips__)
1595 simulator_initialized_ = false;
1596 simulator_i_cache_ = NULL;
1597 simulator_redirection_ = NULL;
1598 #endif
1599
1600 #ifdef DEBUG 1590 #ifdef DEBUG
1601 // heap_histograms_ initializes itself. 1591 // heap_histograms_ initializes itself.
1602 memset(&js_spill_information_, 0, sizeof(js_spill_information_)); 1592 memset(&js_spill_information_, 0, sizeof(js_spill_information_));
1603 memset(code_kind_statistics_, 0,
1604 sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS);
1605 #endif 1593 #endif
1606 1594
1607 #ifdef ENABLE_DEBUGGER_SUPPORT 1595 #ifdef ENABLE_DEBUGGER_SUPPORT
1608 debug_ = NULL; 1596 debug_ = NULL;
1609 debugger_ = NULL; 1597 debugger_ = NULL;
1610 #endif 1598 #endif
1611 1599
1612 handle_scope_data_.Initialize(); 1600 handle_scope_data_.Initialize();
1613 1601
1614 #define ISOLATE_INIT_EXECUTE(type, name, initial_value) \ 1602 #define ISOLATE_INIT_EXECUTE(type, name, initial_value) \
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 if (create_heap_objects) { 2003 if (create_heap_objects) {
2016 // Terminate the cache array with the sentinel so we can iterate. 2004 // Terminate the cache array with the sentinel so we can iterate.
2017 PushToPartialSnapshotCache(heap_.undefined_value()); 2005 PushToPartialSnapshotCache(heap_.undefined_value());
2018 } 2006 }
2019 2007
2020 InitializeThreadLocal(); 2008 InitializeThreadLocal();
2021 2009
2022 bootstrapper_->Initialize(create_heap_objects); 2010 bootstrapper_->Initialize(create_heap_objects);
2023 builtins_.SetUp(this, create_heap_objects); 2011 builtins_.SetUp(this, create_heap_objects);
2024 2012
2013 if (FLAG_log_internal_timer_events) {
2014 set_event_logger(Logger::LogInternalEvents);
2015 } else {
2016 set_event_logger(Logger::EmptyLogInternalEvents);
2017 }
2018
2025 // Set default value if not yet set. 2019 // Set default value if not yet set.
2026 // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults 2020 // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults
2027 // once ResourceConstraints becomes an argument to the Isolate constructor. 2021 // once ResourceConstraints becomes an argument to the Isolate constructor.
2028 if (max_available_threads_ < 1) { 2022 if (max_available_threads_ < 1) {
2029 // Choose the default between 1 and 4. 2023 // Choose the default between 1 and 4.
2030 max_available_threads_ = Max(Min(CPU::NumberOfProcessorsOnline(), 4), 1); 2024 max_available_threads_ = Max(Min(CPU::NumberOfProcessorsOnline(), 4), 1);
2031 } 2025 }
2032 2026
2033 if (!FLAG_job_based_sweeping) { 2027 if (!FLAG_job_based_sweeping) {
2034 num_sweeper_threads_ = 2028 num_sweeper_threads_ =
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 2323
2330 #ifdef DEBUG 2324 #ifdef DEBUG
2331 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2325 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2332 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2326 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2333 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2327 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2334 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2328 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2335 #undef ISOLATE_FIELD_OFFSET 2329 #undef ISOLATE_FIELD_OFFSET
2336 #endif 2330 #endif
2337 2331
2338 } } // namespace v8::internal 2332 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698