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

Side by Side Diff: src/api.cc

Issue 10917236: Not mask exception thrown by toString in String::UtfValue etc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 | « no previous file | test/cctest/test-api.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 5482 matching lines...) Expand 10 before | Expand all | Expand 10 after
5493 } 5493 }
5494 5494
5495 5495
5496 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) 5496 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
5497 : str_(NULL), length_(0) { 5497 : str_(NULL), length_(0) {
5498 i::Isolate* isolate = i::Isolate::Current(); 5498 i::Isolate* isolate = i::Isolate::Current();
5499 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; 5499 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return;
5500 if (obj.IsEmpty()) return; 5500 if (obj.IsEmpty()) return;
5501 ENTER_V8(isolate); 5501 ENTER_V8(isolate);
5502 i::HandleScope scope(isolate); 5502 i::HandleScope scope(isolate);
5503 TryCatch try_catch;
5504 Handle<String> str = obj->ToString(); 5503 Handle<String> str = obj->ToString();
5505 if (str.IsEmpty()) return; 5504 if (str.IsEmpty()) return;
5506 i::Handle<i::String> i_str = Utils::OpenHandle(*str); 5505 i::Handle<i::String> i_str = Utils::OpenHandle(*str);
5507 length_ = i::Utf8Length(i_str); 5506 length_ = i::Utf8Length(i_str);
5508 str_ = i::NewArray<char>(length_ + 1); 5507 str_ = i::NewArray<char>(length_ + 1);
5509 str->WriteUtf8(str_); 5508 str->WriteUtf8(str_);
5510 } 5509 }
5511 5510
5512 5511
5513 String::Utf8Value::~Utf8Value() { 5512 String::Utf8Value::~Utf8Value() {
5514 i::DeleteArray(str_); 5513 i::DeleteArray(str_);
5515 } 5514 }
5516 5515
5517 5516
5518 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) 5517 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj)
5519 : str_(NULL), length_(0) { 5518 : str_(NULL), length_(0) {
5520 i::Isolate* isolate = i::Isolate::Current(); 5519 i::Isolate* isolate = i::Isolate::Current();
5521 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; 5520 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return;
5522 if (obj.IsEmpty()) return; 5521 if (obj.IsEmpty()) return;
5523 ENTER_V8(isolate); 5522 ENTER_V8(isolate);
5524 i::HandleScope scope(isolate); 5523 i::HandleScope scope(isolate);
5525 TryCatch try_catch;
5526 Handle<String> str = obj->ToString(); 5524 Handle<String> str = obj->ToString();
5527 if (str.IsEmpty()) return; 5525 if (str.IsEmpty()) return;
5528 length_ = str->Length(); 5526 length_ = str->Length();
5529 str_ = i::NewArray<char>(length_ + 1); 5527 str_ = i::NewArray<char>(length_ + 1);
5530 str->WriteAscii(str_); 5528 str->WriteAscii(str_);
5531 } 5529 }
5532 5530
5533 5531
5534 String::AsciiValue::~AsciiValue() { 5532 String::AsciiValue::~AsciiValue() {
5535 i::DeleteArray(str_); 5533 i::DeleteArray(str_);
5536 } 5534 }
5537 5535
5538 5536
5539 String::Value::Value(v8::Handle<v8::Value> obj) 5537 String::Value::Value(v8::Handle<v8::Value> obj)
5540 : str_(NULL), length_(0) { 5538 : str_(NULL), length_(0) {
5541 i::Isolate* isolate = i::Isolate::Current(); 5539 i::Isolate* isolate = i::Isolate::Current();
5542 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return; 5540 if (IsDeadCheck(isolate, "v8::String::Value::Value()")) return;
5543 if (obj.IsEmpty()) return; 5541 if (obj.IsEmpty()) return;
5544 ENTER_V8(isolate); 5542 ENTER_V8(isolate);
5545 i::HandleScope scope(isolate); 5543 i::HandleScope scope(isolate);
5546 TryCatch try_catch;
5547 Handle<String> str = obj->ToString(); 5544 Handle<String> str = obj->ToString();
5548 if (str.IsEmpty()) return; 5545 if (str.IsEmpty()) return;
5549 length_ = str->Length(); 5546 length_ = str->Length();
5550 str_ = i::NewArray<uint16_t>(length_ + 1); 5547 str_ = i::NewArray<uint16_t>(length_ + 1);
5551 str->Write(str_); 5548 str->Write(str_);
5552 } 5549 }
5553 5550
5554 5551
5555 String::Value::~Value() { 5552 String::Value::~Value() {
5556 i::DeleteArray(str_); 5553 i::DeleteArray(str_);
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
6577 6574
6578 v->VisitPointers(blocks_.first(), first_block_limit_); 6575 v->VisitPointers(blocks_.first(), first_block_limit_);
6579 6576
6580 for (int i = 1; i < blocks_.length(); i++) { 6577 for (int i = 1; i < blocks_.length(); i++) {
6581 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6578 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6582 } 6579 }
6583 } 6580 }
6584 6581
6585 6582
6586 } } // namespace v8::internal 6583 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698