Commit a294defe authored by jochen@chromium.org's avatar jochen@chromium.org

Remove usage of deprecated APIs from v8 itself

Also turn on depreaction warnings

BUG=v8:3023
R=svenpanne@chromium.org, dcarney@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/83323003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18008 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 686616e4
......@@ -272,7 +272,7 @@ void AllocationTracker::UnresolvedLocation::HandleWeakScript(
void* data) {
UnresolvedLocation* location = reinterpret_cast<UnresolvedLocation*>(data);
location->script_ = Handle<Script>::null();
obj->Dispose();
obj->Reset();
}
......
......@@ -3401,13 +3401,14 @@ Local<Array> v8::Object::GetOwnPropertyNames() {
Local<String> v8::Object::ObjectProtoToString() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()",
i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate);
ON_BAILOUT(i_isolate, "v8::Object::ObjectProtoToString()",
return Local<v8::String>());
ENTER_V8(isolate);
ENTER_V8(i_isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> name(self->class_name(), isolate);
i::Handle<i::Object> name(self->class_name(), i_isolate);
// Native implementation of Object.prototype.toString (v8natives.js):
// var c = %_ClassOf(this);
......@@ -3415,13 +3416,11 @@ Local<String> v8::Object::ObjectProtoToString() {
// return "[object " + c + "]";
if (!name->IsString()) {
return v8::String::New("[object ]");
return v8::String::NewFromUtf8(isolate, "[object ]");
} else {
i::Handle<i::String> class_name = i::Handle<i::String>::cast(name);
if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) {
return v8::String::New("[object Object]");
return v8::String::NewFromUtf8(isolate, "[object Object]");
} else {
const char* prefix = "[object ";
Local<String> str = Utils::ToLocal(class_name);
......@@ -3447,7 +3446,8 @@ Local<String> v8::Object::ObjectProtoToString() {
i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize);
// Copy the buffer into a heap-allocated string and return it.
Local<String> result = v8::String::New(buf.start(), buf_len);
Local<String> result = v8::String::NewFromUtf8(
isolate, buf.start(), String::kNormalString, buf_len);
return result;
}
}
......
......@@ -709,7 +709,7 @@ void ScriptCache::HandleWeakScript(v8::Isolate* isolate,
script_cache->collected_scripts_.Add(id);
// Clear the weak handle.
obj->Dispose();
obj->Reset();
}
......@@ -3071,6 +3071,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
Handle<JSObject> exec_state,
Handle<JSObject> event_data,
bool auto_continue) {
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(isolate_);
HandleScope scope(isolate_);
if (!isolate_->debug()->Load()) return;
......@@ -3131,8 +3132,8 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
{
v8::Local<v8::Object> api_exec_state =
v8::Utils::ToLocal(Handle<JSObject>::cast(exec_state));
v8::Local<v8::String> fun_name =
v8::String::New("debugCommandProcessor");
v8::Local<v8::String> fun_name = v8::String::NewFromUtf8(
isolate, "debugCommandProcessor");
v8::Local<v8::Function> fun =
v8::Local<v8::Function>::Cast(api_exec_state->Get(fun_name));
......@@ -3179,11 +3180,12 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
v8::Local<v8::Function> fun;
v8::Local<v8::Value> request;
v8::TryCatch try_catch;
fun_name = v8::String::New("processDebugRequest");
fun_name = v8::String::NewFromUtf8(isolate, "processDebugRequest");
fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name));
request = v8::String::New(command.text().start(),
command.text().length());
request = v8::String::NewFromTwoByte(isolate, command.text().start(),
v8::String::kNormalString,
command.text().length());
static const int kArgc = 1;
v8::Handle<Value> argv[kArgc] = { request };
v8::Local<v8::Value> response_val = fun->Call(cmd_processor, kArgc, argv);
......@@ -3195,7 +3197,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
if (!response_val->IsUndefined()) {
response = v8::Local<v8::String>::Cast(response_val);
} else {
response = v8::String::New("");
response = v8::String::NewFromUtf8(isolate, "");
}
// Log the JSON request/response.
......@@ -3205,7 +3207,7 @@ void Debugger::NotifyMessageHandler(v8::DebugEvent event,
}
// Get the running state.
fun_name = v8::String::New("isRunning");
fun_name = v8::String::NewFromUtf8(isolate, "isRunning");
fun = v8::Local<v8::Function>::Cast(cmd_processor->Get(fun_name));
static const int kArgc = 1;
v8::Handle<Value> argv[kArgc] = { response };
......
......@@ -75,7 +75,8 @@ v8::Handle<v8::FunctionTemplate> ExternalizeStringExtension::GetNativeFunction(
void ExternalizeStringExtension::Externalize(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() < 1 || !args[0]->IsString()) {
args.GetIsolate()->ThrowException(v8::String::New(
args.GetIsolate()->ThrowException(v8::String::NewFromUtf8(
args.GetIsolate(),
"First parameter to externalizeString() must be a string."));
return;
}
......@@ -84,7 +85,8 @@ void ExternalizeStringExtension::Externalize(
if (args[1]->IsBoolean()) {
force_two_byte = args[1]->BooleanValue();
} else {
args.GetIsolate()->ThrowException(v8::String::New(
args.GetIsolate()->ThrowException(v8::String::NewFromUtf8(
args.GetIsolate(),
"Second parameter to externalizeString() must be a boolean."));
return;
}
......@@ -92,7 +94,8 @@ void ExternalizeStringExtension::Externalize(
bool result = false;
Handle<String> string = Utils::OpenHandle(*args[0].As<v8::String>());
if (string->IsExternalString()) {
args.GetIsolate()->ThrowException(v8::String::New(
args.GetIsolate()->ThrowException(v8::String::NewFromUtf8(
args.GetIsolate(),
"externalizeString() can't externalize twice."));
return;
}
......@@ -120,8 +123,8 @@ void ExternalizeStringExtension::Externalize(
if (!result) delete resource;
}
if (!result) {
args.GetIsolate()->ThrowException(
v8::String::New("externalizeString() failed."));
args.GetIsolate()->ThrowException(v8::String::NewFromUtf8(
args.GetIsolate(), "externalizeString() failed."));
return;
}
}
......@@ -130,7 +133,8 @@ void ExternalizeStringExtension::Externalize(
void ExternalizeStringExtension::IsAscii(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() != 1 || !args[0]->IsString()) {
args.GetIsolate()->ThrowException(v8::String::New(
args.GetIsolate()->ThrowException(v8::String::NewFromUtf8(
args.GetIsolate(),
"isAsciiString() requires a single string argument."));
return;
}
......
......@@ -41,27 +41,30 @@ v8::Handle<v8::FunctionTemplate> StatisticsExtension::GetNativeFunction(
}
static void AddCounter(v8::Local<v8::Object> object,
static void AddCounter(v8::Isolate* isolate,
v8::Local<v8::Object> object,
StatsCounter* counter,
const char* name) {
if (counter->Enabled()) {
object->Set(v8::String::New(name),
object->Set(v8::String::NewFromUtf8(isolate, name),
v8::Number::New(*counter->GetInternalPointer()));
}
}
static void AddNumber(v8::Local<v8::Object> object,
static void AddNumber(v8::Isolate* isolate,
v8::Local<v8::Object> object,
intptr_t value,
const char* name) {
object->Set(v8::String::New(name),
object->Set(v8::String::NewFromUtf8(isolate, name),
v8::Number::New(static_cast<double>(value)));
}
static void AddNumber64(v8::Local<v8::Object> object,
static void AddNumber64(v8::Isolate* isolate,
v8::Local<v8::Object> object,
int64_t value,
const char* name) {
object->Set(v8::String::New(name),
object->Set(v8::String::NewFromUtf8(isolate, name),
v8::Number::New(static_cast<double>(value)));
}
......@@ -81,79 +84,87 @@ void StatisticsExtension::GetCounters(
v8::Local<v8::Object> result = v8::Object::New();
#define ADD_COUNTER(name, caption) \
AddCounter(result, counters->name(), #name);
AddCounter(args.GetIsolate(), result, counters->name(), #name);
STATS_COUNTER_LIST_1(ADD_COUNTER)
STATS_COUNTER_LIST_2(ADD_COUNTER)
#undef ADD_COUNTER
#define ADD_COUNTER(name) \
AddCounter(result, counters->count_of_##name(), "count_of_" #name); \
AddCounter(result, counters->size_of_##name(), "size_of_" #name);
#define ADD_COUNTER(name) \
AddCounter(args.GetIsolate(), result, counters->count_of_##name(), \
"count_of_" #name); \
AddCounter(args.GetIsolate(), result, counters->size_of_##name(), \
"size_of_" #name);
INSTANCE_TYPE_LIST(ADD_COUNTER)
#undef ADD_COUNTER
#define ADD_COUNTER(name) \
AddCounter(result, counters->count_of_CODE_TYPE_##name(), \
"count_of_CODE_TYPE_" #name); \
AddCounter(result, counters->size_of_CODE_TYPE_##name(), \
#define ADD_COUNTER(name) \
AddCounter(args.GetIsolate(), result, counters->count_of_CODE_TYPE_##name(), \
"count_of_CODE_TYPE_" #name); \
AddCounter(args.GetIsolate(), result, counters->size_of_CODE_TYPE_##name(), \
"size_of_CODE_TYPE_" #name);
CODE_KIND_LIST(ADD_COUNTER)
#undef ADD_COUNTER
#define ADD_COUNTER(name) \
AddCounter(result, counters->count_of_FIXED_ARRAY_##name(), \
"count_of_FIXED_ARRAY_" #name); \
AddCounter(result, counters->size_of_FIXED_ARRAY_##name(), \
#define ADD_COUNTER(name) \
AddCounter(args.GetIsolate(), result, \
counters->count_of_FIXED_ARRAY_##name(), \
"count_of_FIXED_ARRAY_" #name); \
AddCounter(args.GetIsolate(), result, \
counters->size_of_FIXED_ARRAY_##name(), \
"size_of_FIXED_ARRAY_" #name);
FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADD_COUNTER)
#undef ADD_COUNTER
AddNumber(result, isolate->memory_allocator()->Size(),
AddNumber(args.GetIsolate(), result, isolate->memory_allocator()->Size(),
"total_committed_bytes");
AddNumber(result, heap->new_space()->Size(),
AddNumber(args.GetIsolate(), result, heap->new_space()->Size(),
"new_space_live_bytes");
AddNumber(result, heap->new_space()->Available(),
AddNumber(args.GetIsolate(), result, heap->new_space()->Available(),
"new_space_available_bytes");
AddNumber(result, heap->new_space()->CommittedMemory(),
AddNumber(args.GetIsolate(), result, heap->new_space()->CommittedMemory(),
"new_space_commited_bytes");
AddNumber(result, heap->old_pointer_space()->Size(),
AddNumber(args.GetIsolate(), result, heap->old_pointer_space()->Size(),
"old_pointer_space_live_bytes");
AddNumber(result, heap->old_pointer_space()->Available(),
AddNumber(args.GetIsolate(), result, heap->old_pointer_space()->Available(),
"old_pointer_space_available_bytes");
AddNumber(result, heap->old_pointer_space()->CommittedMemory(),
AddNumber(args.GetIsolate(), result,
heap->old_pointer_space()->CommittedMemory(),
"old_pointer_space_commited_bytes");
AddNumber(result, heap->old_data_space()->Size(),
AddNumber(args.GetIsolate(), result, heap->old_data_space()->Size(),
"old_data_space_live_bytes");
AddNumber(result, heap->old_data_space()->Available(),
AddNumber(args.GetIsolate(), result, heap->old_data_space()->Available(),
"old_data_space_available_bytes");
AddNumber(result, heap->old_data_space()->CommittedMemory(),
AddNumber(args.GetIsolate(), result,
heap->old_data_space()->CommittedMemory(),
"old_data_space_commited_bytes");
AddNumber(result, heap->code_space()->Size(),
AddNumber(args.GetIsolate(), result, heap->code_space()->Size(),
"code_space_live_bytes");
AddNumber(result, heap->code_space()->Available(),
AddNumber(args.GetIsolate(), result, heap->code_space()->Available(),
"code_space_available_bytes");
AddNumber(result, heap->code_space()->CommittedMemory(),
AddNumber(args.GetIsolate(), result, heap->code_space()->CommittedMemory(),
"code_space_commited_bytes");
AddNumber(result, heap->cell_space()->Size(),
AddNumber(args.GetIsolate(), result, heap->cell_space()->Size(),
"cell_space_live_bytes");
AddNumber(result, heap->cell_space()->Available(),
AddNumber(args.GetIsolate(), result, heap->cell_space()->Available(),
"cell_space_available_bytes");
AddNumber(result, heap->cell_space()->CommittedMemory(),
AddNumber(args.GetIsolate(), result, heap->cell_space()->CommittedMemory(),
"cell_space_commited_bytes");
AddNumber(result, heap->property_cell_space()->Size(),
AddNumber(args.GetIsolate(), result, heap->property_cell_space()->Size(),
"property_cell_space_live_bytes");
AddNumber(result, heap->property_cell_space()->Available(),
AddNumber(args.GetIsolate(), result, heap->property_cell_space()->Available(),
"property_cell_space_available_bytes");
AddNumber(result, heap->property_cell_space()->CommittedMemory(),
AddNumber(args.GetIsolate(), result,
heap->property_cell_space()->CommittedMemory(),
"property_cell_space_commited_bytes");
AddNumber(result, heap->lo_space()->Size(),
AddNumber(args.GetIsolate(), result, heap->lo_space()->Size(),
"lo_space_live_bytes");
AddNumber(result, heap->lo_space()->Available(),
AddNumber(args.GetIsolate(), result, heap->lo_space()->Available(),
"lo_space_available_bytes");
AddNumber(result, heap->lo_space()->CommittedMemory(),
AddNumber(args.GetIsolate(), result, heap->lo_space()->CommittedMemory(),
"lo_space_commited_bytes");
AddNumber64(result, heap->amount_of_external_allocated_memory(),
AddNumber64(args.GetIsolate(), result,
heap->amount_of_external_allocated_memory(),
"amount_of_external_allocated_memory");
args.GetReturnValue().Set(result);
}
......
......@@ -872,7 +872,7 @@ void DateFormat::DeleteDateFormat(v8::Isolate* isolate,
v8::Utils::OpenPersistent(object))->GetInternalField(0));
// Then dispose of the persistent handle to JS object.
object->Dispose();
object->Reset();
}
......@@ -936,7 +936,7 @@ void NumberFormat::DeleteNumberFormat(v8::Isolate* isolate,
v8::Utils::OpenPersistent(object))->GetInternalField(0));
// Then dispose of the persistent handle to JS object.
object->Dispose();
object->Reset();
}
......@@ -997,7 +997,7 @@ void Collator::DeleteCollator(v8::Isolate* isolate,
v8::Utils::OpenPersistent(object))->GetInternalField(0));
// Then dispose of the persistent handle to JS object.
object->Dispose();
object->Reset();
}
......@@ -1064,7 +1064,7 @@ void BreakIterator::DeleteBreakIterator(v8::Isolate* isolate,
v8::Utils::OpenPersistent(object))->GetInternalField(1));
// Then dispose of the persistent handle to JS object.
object->Dispose();
object->Reset();
}
} } // namespace v8::internal
......@@ -332,7 +332,7 @@ int main(int argc, char** argv) {
i += read;
}
fclose(file);
Local<String> source = String::New(chars);
Local<String> source = String::NewFromUtf8(isolate, chars);
TryCatch try_catch;
Local<Script> script = Script::Compile(source);
if (try_catch.HasCaught()) {
......@@ -358,7 +358,7 @@ int main(int argc, char** argv) {
internal_isolate->heap()->CollectAllGarbage(
i::Heap::kNoGCFlags, "mksnapshot");
i::Object* raw_context = *v8::Utils::OpenPersistent(context);
context.Dispose();
context.Reset();
CppByteSink sink(argv[1]);
// This results in a somewhat smaller snapshot, probably because it gets rid
// of some things that are cached between garbage collections.
......
......@@ -30,12 +30,6 @@
'v8_code': 1,
'v8_random_seed%': 314159265,
},
'target_defaults': {
'variables': {
# TODO(jochen): enable warnings.
'v8_deprecation_warnings': 0,
},
},
'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
'targets': [
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment