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

Side by Side Diff: src/api.cc

Issue 1235002: Allow empty handles to escape handle scopes. (Closed)
Patch Set: Created 10 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
« no previous file with comments | « src/api.h ('k') | test/cctest/test-heap.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 530
531 i::Object** v8::HandleScope::RawClose(i::Object** value) { 531 i::Object** v8::HandleScope::RawClose(i::Object** value) {
532 if (!ApiCheck(!is_closed_, 532 if (!ApiCheck(!is_closed_,
533 "v8::HandleScope::Close()", 533 "v8::HandleScope::Close()",
534 "Local scope has already been closed")) { 534 "Local scope has already been closed")) {
535 return 0; 535 return 0;
536 } 536 }
537 LOG_API("CloseHandleScope"); 537 LOG_API("CloseHandleScope");
538 538
539 // Read the result before popping the handle block. 539 // Read the result before popping the handle block.
540 i::Object* result = *value; 540 i::Object* result = NULL;
541 if (value != NULL) {
542 result = *value;
543 }
541 is_closed_ = true; 544 is_closed_ = true;
542 i::HandleScope::Leave(&previous_); 545 i::HandleScope::Leave(&previous_);
543 546
547 if (value == NULL) {
548 return NULL;
549 }
550
544 // Allocate a new handle on the previous handle block. 551 // Allocate a new handle on the previous handle block.
545 i::Handle<i::Object> handle(result); 552 i::Handle<i::Object> handle(result);
546 return handle.location(); 553 return handle.location();
547 } 554 }
548 555
549 556
550 // --- N e a n d e r --- 557 // --- N e a n d e r ---
551 558
552 559
553 // A constructor cannot easily return an error value, therefore it is necessary 560 // A constructor cannot easily return an error value, therefore it is necessary
(...skipping 3512 matching lines...) Expand 10 before | Expand all | Expand 10 after
4066 4073
4067 4074
4068 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4075 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4069 HandleScopeImplementer* thread_local = 4076 HandleScopeImplementer* thread_local =
4070 reinterpret_cast<HandleScopeImplementer*>(storage); 4077 reinterpret_cast<HandleScopeImplementer*>(storage);
4071 thread_local->IterateThis(v); 4078 thread_local->IterateThis(v);
4072 return storage + ArchiveSpacePerThread(); 4079 return storage + ArchiveSpacePerThread();
4073 } 4080 }
4074 4081
4075 } } // namespace v8::internal 4082 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698