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

Side by Side Diff: src/isolate.cc

Issue 14403015: Disallow dereferencing deferred handles when generating optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 8 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/objects.cc » ('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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 500
501 void Isolate::IterateDeferredHandles(ObjectVisitor* visitor) { 501 void Isolate::IterateDeferredHandles(ObjectVisitor* visitor) {
502 for (DeferredHandles* deferred = deferred_handles_head_; 502 for (DeferredHandles* deferred = deferred_handles_head_;
503 deferred != NULL; 503 deferred != NULL;
504 deferred = deferred->next_) { 504 deferred = deferred->next_) {
505 deferred->Iterate(visitor); 505 deferred->Iterate(visitor);
506 } 506 }
507 } 507 }
508 508
509 509
510 #ifdef DEBUG
511 bool Isolate::IsDeferredHandle(Object** handle) {
512 // Each DeferredHandles instance keeps the handles to one job in the
513 // parallel recompilation queue, containing a list of blocks. Each block
514 // contains kHandleBlockSize handles except for the first block, which may
515 // not be fully filled.
516 // We iterate through all the blocks to see whether the argument handle
517 // belongs to one of the blocks. If so, it is deferred.
518 for (DeferredHandles* deferred = deferred_handles_head_;
519 deferred != NULL;
520 deferred = deferred->next_) {
521 List<Object**>* blocks = &deferred->blocks_;
522 for (int i = 0; i < blocks->length(); i++) {
523 Object** block_limit = (i == 0) ? deferred->first_block_limit_
524 : blocks->at(i) + kHandleBlockSize;
525 if (blocks->at(i) <= handle && handle < block_limit) return true;
526 }
527 }
528 return false;
529 }
530 #endif // DEBUG
531
532
510 void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) { 533 void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) {
511 // The ARM simulator has a separate JS stack. We therefore register 534 // The ARM simulator has a separate JS stack. We therefore register
512 // the C++ try catch handler with the simulator and get back an 535 // the C++ try catch handler with the simulator and get back an
513 // address that can be used for comparisons with addresses into the 536 // address that can be used for comparisons with addresses into the
514 // JS stack. When running without the simulator, the address 537 // JS stack. When running without the simulator, the address
515 // returned will be the address of the C++ try catch handler itself. 538 // returned will be the address of the C++ try catch handler itself.
516 Address address = reinterpret_cast<Address>( 539 Address address = reinterpret_cast<Address>(
517 SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that))); 540 SimulatorStack::RegisterCTryCatch(reinterpret_cast<uintptr_t>(that)));
518 thread_local_top()->set_try_catch_handler_address(address); 541 thread_local_top()->set_try_catch_handler_address(address);
519 } 542 }
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 simulator_i_cache_ = NULL; 1773 simulator_i_cache_ = NULL;
1751 simulator_redirection_ = NULL; 1774 simulator_redirection_ = NULL;
1752 #endif 1775 #endif
1753 1776
1754 #ifdef DEBUG 1777 #ifdef DEBUG
1755 // heap_histograms_ initializes itself. 1778 // heap_histograms_ initializes itself.
1756 memset(&js_spill_information_, 0, sizeof(js_spill_information_)); 1779 memset(&js_spill_information_, 0, sizeof(js_spill_information_));
1757 memset(code_kind_statistics_, 0, 1780 memset(code_kind_statistics_, 0,
1758 sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS); 1781 sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS);
1759 1782
1760 allow_compiler_thread_handle_deref_ = true; 1783 compiler_thread_handle_deref_state_ = HandleDereferenceGuard::ALLOW;
1761 allow_execution_thread_handle_deref_ = true; 1784 execution_thread_handle_deref_state_ = HandleDereferenceGuard::ALLOW;
1762 #endif 1785 #endif
1763 1786
1764 #ifdef ENABLE_DEBUGGER_SUPPORT 1787 #ifdef ENABLE_DEBUGGER_SUPPORT
1765 debug_ = NULL; 1788 debug_ = NULL;
1766 debugger_ = NULL; 1789 debugger_ = NULL;
1767 #endif 1790 #endif
1768 1791
1769 handle_scope_data_.Initialize(); 1792 handle_scope_data_.Initialize();
1770 1793
1771 #define ISOLATE_INIT_EXECUTE(type, name, initial_value) \ 1794 #define ISOLATE_INIT_EXECUTE(type, name, initial_value) \
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 if (deferred->next_ != NULL) { 2395 if (deferred->next_ != NULL) {
2373 deferred->next_->previous_ = deferred->previous_; 2396 deferred->next_->previous_ = deferred->previous_;
2374 } 2397 }
2375 if (deferred->previous_ != NULL) { 2398 if (deferred->previous_ != NULL) {
2376 deferred->previous_->next_ = deferred->next_; 2399 deferred->previous_->next_ = deferred->next_;
2377 } 2400 }
2378 } 2401 }
2379 2402
2380 2403
2381 #ifdef DEBUG 2404 #ifdef DEBUG
2382 bool Isolate::AllowHandleDereference() { 2405 HandleDereferenceGuard::State Isolate::HandleDereferenceGuardState() {
2383 if (allow_execution_thread_handle_deref_ && 2406 if (execution_thread_handle_deref_state_ == HandleDereferenceGuard::ALLOW &&
2384 allow_compiler_thread_handle_deref_) { 2407 compiler_thread_handle_deref_state_ == HandleDereferenceGuard::ALLOW) {
2385 // Short-cut to avoid polling thread id. 2408 // Short-cut to avoid polling thread id.
2386 return true; 2409 return HandleDereferenceGuard::ALLOW;
2387 } 2410 }
2388 if (FLAG_parallel_recompilation && 2411 if (FLAG_parallel_recompilation &&
2389 optimizing_compiler_thread()->IsOptimizerThread()) { 2412 optimizing_compiler_thread()->IsOptimizerThread()) {
2390 return allow_compiler_thread_handle_deref_; 2413 return compiler_thread_handle_deref_state_;
2391 } else { 2414 } else {
2392 return allow_execution_thread_handle_deref_; 2415 return execution_thread_handle_deref_state_;
2393 } 2416 }
2394 } 2417 }
2395 2418
2396 2419
2397 void Isolate::SetAllowHandleDereference(bool allow) { 2420 void Isolate::SetHandleDereferenceGuardState(
2421 HandleDereferenceGuard::State state) {
2398 if (FLAG_parallel_recompilation && 2422 if (FLAG_parallel_recompilation &&
2399 optimizing_compiler_thread()->IsOptimizerThread()) { 2423 optimizing_compiler_thread()->IsOptimizerThread()) {
2400 allow_compiler_thread_handle_deref_ = allow; 2424 compiler_thread_handle_deref_state_ = state;
2401 } else { 2425 } else {
2402 allow_execution_thread_handle_deref_ = allow; 2426 execution_thread_handle_deref_state_ = state;
2403 } 2427 }
2404 } 2428 }
2405 #endif 2429 #endif
2406 2430
2407 2431
2408 HStatistics* Isolate::GetHStatistics() { 2432 HStatistics* Isolate::GetHStatistics() {
2409 if (hstatistics() == NULL) set_hstatistics(new HStatistics()); 2433 if (hstatistics() == NULL) set_hstatistics(new HStatistics());
2410 return hstatistics(); 2434 return hstatistics();
2411 } 2435 }
2412 2436
(...skipping 12 matching lines...) Expand all
2425 2449
2426 #ifdef DEBUG 2450 #ifdef DEBUG
2427 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2451 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2428 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2452 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2429 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2453 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2430 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2454 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2431 #undef ISOLATE_FIELD_OFFSET 2455 #undef ISOLATE_FIELD_OFFSET
2432 #endif 2456 #endif
2433 2457
2434 } } // namespace v8::internal 2458 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698