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/api.cc

Issue 99193002: Remove all stuff marked as V8_DEPRECATED. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 void V8::SetFlagsFromString(const char* str, int length) { 465 void V8::SetFlagsFromString(const char* str, int length) {
466 i::FlagList::SetFlagsFromString(str, length); 466 i::FlagList::SetFlagsFromString(str, length);
467 } 467 }
468 468
469 469
470 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { 470 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
471 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); 471 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
472 } 472 }
473 473
474 474
475 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) {
476 return v8::Isolate::GetCurrent()->ThrowException(value);
477 }
478
479
480 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; 475 RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
481 476
482 477
483 RegisteredExtension::RegisteredExtension(Extension* extension) 478 RegisteredExtension::RegisteredExtension(Extension* extension)
484 : extension_(extension) { } 479 : extension_(extension) { }
485 480
486 481
487 void RegisteredExtension::Register(RegisteredExtension* that) { 482 void RegisteredExtension::Register(RegisteredExtension* that) {
488 that->next_ = first_extension_; 483 that->next_ = first_extension_;
489 first_extension_ = that; 484 first_extension_ = that;
(...skipping 26 matching lines...) Expand all
516 source_length : 511 source_length :
517 (source ? static_cast<int>(strlen(source)) : 0)), 512 (source ? static_cast<int>(strlen(source)) : 0)),
518 source_(source, source_length_), 513 source_(source, source_length_),
519 dep_count_(dep_count), 514 dep_count_(dep_count),
520 deps_(deps), 515 deps_(deps),
521 auto_enable_(false) { 516 auto_enable_(false) {
522 CHECK(source != NULL || source_length_ == 0); 517 CHECK(source != NULL || source_length_ == 0);
523 } 518 }
524 519
525 520
526 v8::Handle<Primitive> Undefined() {
527 i::Isolate* isolate = i::Isolate::Current();
528 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
529 return v8::Handle<v8::Primitive>();
530 }
531 return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
532 }
533
534
535 v8::Handle<Primitive> Null() {
536 i::Isolate* isolate = i::Isolate::Current();
537 if (!EnsureInitializedForIsolate(isolate, "v8::Null()")) {
538 return v8::Handle<v8::Primitive>();
539 }
540 return ToApiHandle<Primitive>(isolate->factory()->null_value());
541 }
542
543
544 v8::Handle<Boolean> True() {
545 i::Isolate* isolate = i::Isolate::Current();
546 if (!EnsureInitializedForIsolate(isolate, "v8::True()")) {
547 return v8::Handle<Boolean>();
548 }
549 return ToApiHandle<Boolean>(isolate->factory()->true_value());
550 }
551
552
553 v8::Handle<Boolean> False() {
554 i::Isolate* isolate = i::Isolate::Current();
555 if (!EnsureInitializedForIsolate(isolate, "v8::False()")) {
556 return v8::Handle<Boolean>();
557 }
558 return ToApiHandle<Boolean>(isolate->factory()->false_value());
559 }
560
561
562 ResourceConstraints::ResourceConstraints() 521 ResourceConstraints::ResourceConstraints()
563 : max_young_space_size_(0), 522 : max_young_space_size_(0),
564 max_old_space_size_(0), 523 max_old_space_size_(0),
565 max_executable_size_(0), 524 max_executable_size_(0),
566 stack_limit_(NULL), 525 stack_limit_(NULL),
567 max_available_threads_(0) { } 526 max_available_threads_(0) { }
568 527
569 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, 528 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
570 uint32_t number_of_processors) { 529 uint32_t number_of_processors) {
571 const int lump_of_memory = (i::kPointerSize / 4) * i::MB; 530 const int lump_of_memory = (i::kPointerSize / 4) * i::MB;
(...skipping 26 matching lines...) Expand all
598 } else { 557 } else {
599 set_max_young_space_size(16 * lump_of_memory); 558 set_max_young_space_size(16 * lump_of_memory);
600 set_max_old_space_size(700 * lump_of_memory); 559 set_max_old_space_size(700 * lump_of_memory);
601 set_max_executable_size(256 * lump_of_memory); 560 set_max_executable_size(256 * lump_of_memory);
602 } 561 }
603 562
604 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u)); 563 set_max_available_threads(i::Max(i::Min(number_of_processors, 4u), 1u));
605 } 564 }
606 565
607 566
608 void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory) {
609 ConfigureDefaults(physical_memory, i::CPU::NumberOfProcessorsOnline());
610 }
611
612
613 bool SetResourceConstraints(Isolate* v8_isolate, 567 bool SetResourceConstraints(Isolate* v8_isolate,
614 ResourceConstraints* constraints) { 568 ResourceConstraints* constraints) {
615 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 569 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
616 int young_space_size = constraints->max_young_space_size(); 570 int young_space_size = constraints->max_young_space_size();
617 int old_gen_size = constraints->max_old_space_size(); 571 int old_gen_size = constraints->max_old_space_size();
618 int max_executable_size = constraints->max_executable_size(); 572 int max_executable_size = constraints->max_executable_size();
619 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) { 573 if (young_space_size != 0 || old_gen_size != 0 || max_executable_size != 0) {
620 // After initialization it's too late to change Heap constraints. 574 // After initialization it's too late to change Heap constraints.
621 ASSERT(!isolate->IsInitialized()); 575 ASSERT(!isolate->IsInitialized());
622 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2, 576 bool result = isolate->heap()->ConfigureHeap(young_space_size / 2,
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 for (int i = 0; i < argc; i++) { 1071 for (int i = 0; i < argc; i++) {
1118 if (!argv[i].IsEmpty()) 1072 if (!argv[i].IsEmpty())
1119 args->set(i, *Utils::OpenHandle(*argv[i])); 1073 args->set(i, *Utils::OpenHandle(*argv[i]));
1120 } 1074 }
1121 obj->set_args(*args); 1075 obj->set_args(*args);
1122 } 1076 }
1123 return Utils::ToLocal(obj); 1077 return Utils::ToLocal(obj);
1124 } 1078 }
1125 1079
1126 1080
1127 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver,
1128 int argc, Handle<FunctionTemplate> argv[]) {
1129 return New(Isolate::GetCurrent(), receiver, argc, argv);
1130 }
1131
1132
1133 Local<AccessorSignature> AccessorSignature::New( 1081 Local<AccessorSignature> AccessorSignature::New(
1134 Isolate* isolate, 1082 Isolate* isolate,
1135 Handle<FunctionTemplate> receiver) { 1083 Handle<FunctionTemplate> receiver) {
1136 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); 1084 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
1137 } 1085 }
1138 1086
1139 1087
1140 // While this is just a cast, it's lame not to use an Isolate parameter.
1141 Local<AccessorSignature> AccessorSignature::New(
1142 Handle<FunctionTemplate> receiver) {
1143 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver));
1144 }
1145
1146
1147 template<typename Operation> 1088 template<typename Operation>
1148 static Local<Operation> NewDescriptor( 1089 static Local<Operation> NewDescriptor(
1149 Isolate* isolate, 1090 Isolate* isolate,
1150 const i::DeclaredAccessorDescriptorData& data, 1091 const i::DeclaredAccessorDescriptorData& data,
1151 Data* previous_descriptor) { 1092 Data* previous_descriptor) {
1152 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 1093 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
1153 i::Handle<i::DeclaredAccessorDescriptor> previous = 1094 i::Handle<i::DeclaredAccessorDescriptor> previous =
1154 i::Handle<i::DeclaredAccessorDescriptor>(); 1095 i::Handle<i::DeclaredAccessorDescriptor>();
1155 if (previous_descriptor != NULL) { 1096 if (previous_descriptor != NULL) {
1156 previous = Utils::OpenHandle( 1097 previous = Utils::OpenHandle(
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 result = 1854 result =
1914 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); 1855 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1915 } else { 1856 } else {
1916 result = 1857 result =
1917 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()); 1858 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared());
1918 } 1859 }
1919 return result; 1860 return result;
1920 } 1861 }
1921 1862
1922 1863
1923 Local<Value> Script::Id() {
1924 i::Handle<i::HeapObject> obj =
1925 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1926 i::Isolate* isolate = obj->GetIsolate();
1927 ON_BAILOUT(isolate, "v8::Script::Id()", return Local<Value>());
1928 LOG_API(isolate, "Script::Id");
1929 i::Object* raw_id = NULL;
1930 {
1931 i::HandleScope scope(isolate);
1932 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1933 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1934 i::Handle<i::Object> id(script->id(), isolate);
1935 raw_id = *id;
1936 }
1937 i::Handle<i::Object> id(raw_id, isolate);
1938 return Utils::ToLocal(id);
1939 }
1940
1941
1942 int Script::GetId() { 1864 int Script::GetId() {
1943 i::Handle<i::HeapObject> obj = 1865 i::Handle<i::HeapObject> obj =
1944 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); 1866 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1945 i::Isolate* isolate = obj->GetIsolate(); 1867 i::Isolate* isolate = obj->GetIsolate();
1946 ON_BAILOUT(isolate, "v8::Script::Id()", return -1); 1868 ON_BAILOUT(isolate, "v8::Script::Id()", return -1);
1947 LOG_API(isolate, "Script::Id"); 1869 LOG_API(isolate, "Script::Id");
1948 { 1870 {
1949 i::HandleScope scope(isolate); 1871 i::HandleScope scope(isolate);
1950 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); 1872 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1951 i::Handle<i::Script> script(i::Script::cast(function_info->script())); 1873 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 } 2236 }
2315 2237
2316 2238
2317 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { 2239 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) {
2318 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 2240 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2319 ENTER_V8(i_isolate); 2241 ENTER_V8(i_isolate);
2320 i_isolate->PrintCurrentStackTrace(out); 2242 i_isolate->PrintCurrentStackTrace(out);
2321 } 2243 }
2322 2244
2323 2245
2324 void Message::PrintCurrentStackTrace(FILE* out) {
2325 PrintCurrentStackTrace(Isolate::GetCurrent(), out);
2326 }
2327
2328
2329 // --- S t a c k T r a c e --- 2246 // --- S t a c k T r a c e ---
2330 2247
2331 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 2248 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
2332 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2249 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2333 ENTER_V8(isolate); 2250 ENTER_V8(isolate);
2334 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2251 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
2335 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 2252 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
2336 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); 2253 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index);
2337 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); 2254 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
2338 return scope.Close(Utils::StackFrameToLocal(obj)); 2255 return scope.Close(Utils::StackFrameToLocal(obj));
(...skipping 19 matching lines...) Expand all
2358 int frame_limit, 2275 int frame_limit,
2359 StackTraceOptions options) { 2276 StackTraceOptions options) {
2360 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 2277 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2361 ENTER_V8(i_isolate); 2278 ENTER_V8(i_isolate);
2362 i::Handle<i::JSArray> stackTrace = 2279 i::Handle<i::JSArray> stackTrace =
2363 i_isolate->CaptureCurrentStackTrace(frame_limit, options); 2280 i_isolate->CaptureCurrentStackTrace(frame_limit, options);
2364 return Utils::StackTraceToLocal(stackTrace); 2281 return Utils::StackTraceToLocal(stackTrace);
2365 } 2282 }
2366 2283
2367 2284
2368 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit,
2369 StackTraceOptions options) {
2370 return CurrentStackTrace(Isolate::GetCurrent(), frame_limit, options);
2371 }
2372
2373
2374 // --- S t a c k F r a m e --- 2285 // --- S t a c k F r a m e ---
2375 2286
2376 int StackFrame::GetLineNumber() const { 2287 int StackFrame::GetLineNumber() const {
2377 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2288 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2378 ENTER_V8(isolate); 2289 ENTER_V8(isolate);
2379 i::HandleScope scope(isolate); 2290 i::HandleScope scope(isolate);
2380 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2291 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2381 i::Handle<i::Object> line = GetProperty(self, "lineNumber"); 2292 i::Handle<i::Object> line = GetProperty(self, "lineNumber");
2382 if (!line->IsSmi()) { 2293 if (!line->IsSmi()) {
2383 return Message::kNoLineNumberInfo; 2294 return Message::kNoLineNumberInfo;
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
4279 return kLineOffsetNotFound; 4190 return kLineOffsetNotFound;
4280 } 4191 }
4281 4192
4282 4193
4283 bool Function::IsBuiltin() const { 4194 bool Function::IsBuiltin() const {
4284 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4195 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4285 return func->IsBuiltin(); 4196 return func->IsBuiltin();
4286 } 4197 }
4287 4198
4288 4199
4289 Handle<Value> Function::GetScriptId() const {
4290 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4291 i::Isolate* isolate = func->GetIsolate();
4292 if (!func->shared()->script()->IsScript()) {
4293 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
4294 }
4295 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4296 return Utils::ToLocal(i::Handle<i::Object>(script->id(), isolate));
4297 }
4298
4299
4300 int Function::ScriptId() const { 4200 int Function::ScriptId() const {
4301 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); 4201 i::Handle<i::JSFunction> func = Utils::OpenHandle(this);
4302 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId; 4202 if (!func->shared()->script()->IsScript()) return v8::Script::kNoScriptId;
4303 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); 4203 i::Handle<i::Script> script(i::Script::cast(func->shared()->script()));
4304 return script->id()->value(); 4204 return script->id()->value();
4305 } 4205 }
4306 4206
4307 4207
4308 int String::Length() const { 4208 int String::Length() const {
4309 i::Handle<i::String> str = Utils::OpenHandle(this); 4209 i::Handle<i::String> str = Utils::OpenHandle(this);
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
5367 return Utils::ToLocal(token_handle); 5267 return Utils::ToLocal(token_handle);
5368 } 5268 }
5369 5269
5370 5270
5371 bool Context::HasOutOfMemoryException() { 5271 bool Context::HasOutOfMemoryException() {
5372 i::Handle<i::Context> env = Utils::OpenHandle(this); 5272 i::Handle<i::Context> env = Utils::OpenHandle(this);
5373 return env->has_out_of_memory(); 5273 return env->has_out_of_memory();
5374 } 5274 }
5375 5275
5376 5276
5377 bool Context::InContext() {
5378 return i::Isolate::Current()->context() != NULL;
5379 }
5380
5381
5382 v8::Isolate* Context::GetIsolate() { 5277 v8::Isolate* Context::GetIsolate() {
5383 i::Handle<i::Context> env = Utils::OpenHandle(this); 5278 i::Handle<i::Context> env = Utils::OpenHandle(this);
5384 return reinterpret_cast<Isolate*>(env->GetIsolate()); 5279 return reinterpret_cast<Isolate*>(env->GetIsolate());
5385 } 5280 }
5386 5281
5387 5282
5388 v8::Local<v8::Context> Context::GetEntered() {
5389 i::Isolate* isolate = i::Isolate::Current();
5390 if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) {
5391 return Local<Context>();
5392 }
5393 return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext();
5394 }
5395
5396
5397 v8::Local<v8::Context> Context::GetCurrent() {
5398 i::Isolate* isolate = i::Isolate::Current();
5399 return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext();
5400 }
5401
5402
5403 v8::Local<v8::Context> Context::GetCalling() {
5404 i::Isolate* isolate = i::Isolate::Current();
5405 return reinterpret_cast<Isolate*>(isolate)->GetCallingContext();
5406 }
5407
5408
5409 v8::Local<v8::Object> Context::Global() { 5283 v8::Local<v8::Object> Context::Global() {
5410 i::Handle<i::Context> context = Utils::OpenHandle(this); 5284 i::Handle<i::Context> context = Utils::OpenHandle(this);
5411 i::Isolate* isolate = context->GetIsolate(); 5285 i::Isolate* isolate = context->GetIsolate();
5412 i::Handle<i::Object> global(context->global_proxy(), isolate); 5286 i::Handle<i::Object> global(context->global_proxy(), isolate);
5413 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 5287 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
5414 } 5288 }
5415 5289
5416 5290
5417 void Context::DetachGlobal() { 5291 void Context::DetachGlobal() {
5418 i::Handle<i::Context> context = Utils::OpenHandle(this); 5292 i::Handle<i::Context> context = Utils::OpenHandle(this);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5497 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); 5371 STATIC_ASSERT(sizeof(value) == sizeof(i::Address));
5498 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5372 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5499 EnsureInitializedForIsolate(i_isolate, "v8::External::New()"); 5373 EnsureInitializedForIsolate(i_isolate, "v8::External::New()");
5500 LOG_API(i_isolate, "External::New"); 5374 LOG_API(i_isolate, "External::New");
5501 ENTER_V8(i_isolate); 5375 ENTER_V8(i_isolate);
5502 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); 5376 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value);
5503 return Utils::ExternalToLocal(external); 5377 return Utils::ExternalToLocal(external);
5504 } 5378 }
5505 5379
5506 5380
5507 Local<External> v8::External::New(void* value) {
5508 return v8::External::New(Isolate::GetCurrent(), value);
5509 }
5510
5511
5512 void* External::Value() const { 5381 void* External::Value() const {
5513 return ExternalValue(*Utils::OpenHandle(this)); 5382 return ExternalValue(*Utils::OpenHandle(this));
5514 } 5383 }
5515 5384
5516 5385
5517 Local<String> v8::String::Empty() { 5386 Local<String> v8::String::Empty() {
5518 i::Isolate* isolate = i::Isolate::Current(); 5387 i::Isolate* isolate = i::Isolate::Current();
5519 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) { 5388 if (!EnsureInitializedForIsolate(isolate, "v8::String::Empty()")) {
5520 return v8::Local<String>(); 5389 return v8::Local<String>();
5521 } 5390 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
5693 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); 5562 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
5694 LOG_API(i_isolate, "String::NewExternal"); 5563 LOG_API(i_isolate, "String::NewExternal");
5695 ENTER_V8(i_isolate); 5564 ENTER_V8(i_isolate);
5696 CHECK(resource && resource->data()); 5565 CHECK(resource && resource->data());
5697 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); 5566 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource);
5698 i_isolate->heap()->external_string_table()->AddString(*result); 5567 i_isolate->heap()->external_string_table()->AddString(*result);
5699 return Utils::ToLocal(result); 5568 return Utils::ToLocal(result);
5700 } 5569 }
5701 5570
5702 5571
5703 Local<String> v8::String::NewExternal(
5704 v8::String::ExternalStringResource* resource) {
5705 return NewExternal(Isolate::GetCurrent(), resource);
5706 }
5707
5708
5709 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { 5572 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
5710 i::Handle<i::String> obj = Utils::OpenHandle(this); 5573 i::Handle<i::String> obj = Utils::OpenHandle(this);
5711 i::Isolate* isolate = obj->GetIsolate(); 5574 i::Isolate* isolate = obj->GetIsolate();
5712 if (i::StringShape(*obj).IsExternalTwoByte()) { 5575 if (i::StringShape(*obj).IsExternalTwoByte()) {
5713 return false; // Already an external string. 5576 return false; // Already an external string.
5714 } 5577 }
5715 ENTER_V8(isolate); 5578 ENTER_V8(isolate);
5716 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 5579 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5717 return false; 5580 return false;
5718 } 5581 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5750 LOG_API(i_isolate, "String::NewExternal"); 5613 LOG_API(i_isolate, "String::NewExternal");
5751 ENTER_V8(i_isolate); 5614 ENTER_V8(i_isolate);
5752 CHECK(resource && resource->data()); 5615 CHECK(resource && resource->data());
5753 i::Handle<i::String> result = 5616 i::Handle<i::String> result =
5754 NewExternalAsciiStringHandle(i_isolate, resource); 5617 NewExternalAsciiStringHandle(i_isolate, resource);
5755 i_isolate->heap()->external_string_table()->AddString(*result); 5618 i_isolate->heap()->external_string_table()->AddString(*result);
5756 return Utils::ToLocal(result); 5619 return Utils::ToLocal(result);
5757 } 5620 }
5758 5621
5759 5622
5760 Local<String> v8::String::NewExternal(
5761 v8::String::ExternalAsciiStringResource* resource) {
5762 return NewExternal(Isolate::GetCurrent(), resource);
5763 }
5764
5765
5766 bool v8::String::MakeExternal( 5623 bool v8::String::MakeExternal(
5767 v8::String::ExternalAsciiStringResource* resource) { 5624 v8::String::ExternalAsciiStringResource* resource) {
5768 i::Handle<i::String> obj = Utils::OpenHandle(this); 5625 i::Handle<i::String> obj = Utils::OpenHandle(this);
5769 i::Isolate* isolate = obj->GetIsolate(); 5626 i::Isolate* isolate = obj->GetIsolate();
5770 if (i::StringShape(*obj).IsExternalTwoByte()) { 5627 if (i::StringShape(*obj).IsExternalTwoByte()) {
5771 return false; // Already an external string. 5628 return false; // Already an external string.
5772 } 5629 }
5773 ENTER_V8(isolate); 5630 ENTER_V8(isolate);
5774 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 5631 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
5775 return false; 5632 return false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5838 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5695 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5839 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); 5696 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()");
5840 LOG_API(i_isolate, "NumberObject::New"); 5697 LOG_API(i_isolate, "NumberObject::New");
5841 ENTER_V8(i_isolate); 5698 ENTER_V8(i_isolate);
5842 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); 5699 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
5843 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); 5700 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number);
5844 return Utils::ToLocal(obj); 5701 return Utils::ToLocal(obj);
5845 } 5702 }
5846 5703
5847 5704
5848 Local<v8::Value> v8::NumberObject::New(double value) {
5849 return New(Isolate::GetCurrent(), value);
5850 }
5851
5852
5853 double v8::NumberObject::ValueOf() const { 5705 double v8::NumberObject::ValueOf() const {
5854 i::Isolate* isolate = i::Isolate::Current(); 5706 i::Isolate* isolate = i::Isolate::Current();
5855 LOG_API(isolate, "NumberObject::NumberValue"); 5707 LOG_API(isolate, "NumberObject::NumberValue");
5856 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5708 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5857 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5709 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5858 return jsvalue->value()->Number(); 5710 return jsvalue->value()->Number();
5859 } 5711 }
5860 5712
5861 5713
5862 Local<v8::Value> v8::BooleanObject::New(bool value) { 5714 Local<v8::Value> v8::BooleanObject::New(bool value) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5934 } 5786 }
5935 ENTER_V8(i_isolate); 5787 ENTER_V8(i_isolate);
5936 EXCEPTION_PREAMBLE(i_isolate); 5788 EXCEPTION_PREAMBLE(i_isolate);
5937 i::Handle<i::Object> obj = 5789 i::Handle<i::Object> obj =
5938 i::Execution::NewDate(i_isolate, time, &has_pending_exception); 5790 i::Execution::NewDate(i_isolate, time, &has_pending_exception);
5939 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); 5791 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>());
5940 return Utils::ToLocal(obj); 5792 return Utils::ToLocal(obj);
5941 } 5793 }
5942 5794
5943 5795
5944 Local<v8::Value> v8::Date::New(double time) {
5945 return New(Isolate::GetCurrent(), time);
5946 }
5947
5948
5949 double v8::Date::ValueOf() const { 5796 double v8::Date::ValueOf() const {
5950 i::Isolate* isolate = i::Isolate::Current(); 5797 i::Isolate* isolate = i::Isolate::Current();
5951 LOG_API(isolate, "Date::NumberValue"); 5798 LOG_API(isolate, "Date::NumberValue");
5952 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5799 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5953 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); 5800 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj);
5954 return jsdate->value()->Number(); 5801 return jsdate->value()->Number();
5955 } 5802 }
5956 5803
5957 5804
5958 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { 5805 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) {
(...skipping 25 matching lines...) Expand all
5984 bool caught_exception = false; 5831 bool caught_exception = false;
5985 i::Execution::TryCall(func, 5832 i::Execution::TryCall(func,
5986 i_isolate->js_builtins_object(), 5833 i_isolate->js_builtins_object(),
5987 0, 5834 0,
5988 NULL, 5835 NULL,
5989 &caught_exception); 5836 &caught_exception);
5990 } 5837 }
5991 } 5838 }
5992 5839
5993 5840
5994 void v8::Date::DateTimeConfigurationChangeNotification() {
5995 DateTimeConfigurationChangeNotification(Isolate::GetCurrent());
5996 }
5997
5998
5999 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { 5841 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
6000 i::Isolate* isolate = i::Isolate::Current(); 5842 i::Isolate* isolate = i::Isolate::Current();
6001 uint8_t flags_buf[3]; 5843 uint8_t flags_buf[3];
6002 int num_flags = 0; 5844 int num_flags = 0;
6003 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; 5845 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
6004 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; 5846 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
6005 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; 5847 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
6006 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); 5848 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
6007 return isolate->factory()->InternalizeOneByteString( 5849 return isolate->factory()->InternalizeOneByteString(
6008 i::Vector<const uint8_t>(flags_buf, num_flags)); 5850 i::Vector<const uint8_t>(flags_buf, num_flags));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6054 ENTER_V8(i_isolate); 5896 ENTER_V8(i_isolate);
6055 int real_length = length > 0 ? length : 0; 5897 int real_length = length > 0 ? length : 0;
6056 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); 5898 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length);
6057 i::Handle<i::Object> length_obj = 5899 i::Handle<i::Object> length_obj =
6058 i_isolate->factory()->NewNumberFromInt(real_length); 5900 i_isolate->factory()->NewNumberFromInt(real_length);
6059 obj->set_length(*length_obj); 5901 obj->set_length(*length_obj);
6060 return Utils::ToLocal(obj); 5902 return Utils::ToLocal(obj);
6061 } 5903 }
6062 5904
6063 5905
6064 Local<v8::Array> v8::Array::New(int length) {
6065 return New(Isolate::GetCurrent(), length);
6066 }
6067
6068
6069 uint32_t v8::Array::Length() const { 5906 uint32_t v8::Array::Length() const {
6070 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); 5907 i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
6071 i::Object* length = obj->length(); 5908 i::Object* length = obj->length();
6072 if (length->IsSmi()) { 5909 if (length->IsSmi()) {
6073 return i::Smi::cast(length)->value(); 5910 return i::Smi::cast(length)->value();
6074 } else { 5911 } else {
6075 return static_cast<uint32_t>(length->Number()); 5912 return static_cast<uint32_t>(length->Number());
6076 } 5913 }
6077 } 5914 }
6078 5915
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
6154 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); 5991 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)");
6155 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); 5992 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)");
6156 ENTER_V8(i_isolate); 5993 ENTER_V8(i_isolate);
6157 i::Handle<i::JSArrayBuffer> obj = 5994 i::Handle<i::JSArrayBuffer> obj =
6158 i_isolate->factory()->NewJSArrayBuffer(); 5995 i_isolate->factory()->NewJSArrayBuffer();
6159 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); 5996 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length);
6160 return Utils::ToLocal(obj); 5997 return Utils::ToLocal(obj);
6161 } 5998 }
6162 5999
6163 6000
6164 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) {
6165 return New(Isolate::GetCurrent(), byte_length);
6166 }
6167
6168
6169 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, 6001 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
6170 size_t byte_length) { 6002 size_t byte_length) {
6171 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6003 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6172 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); 6004 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6173 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); 6005 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6174 ENTER_V8(i_isolate); 6006 ENTER_V8(i_isolate);
6175 i::Handle<i::JSArrayBuffer> obj = 6007 i::Handle<i::JSArrayBuffer> obj =
6176 i_isolate->factory()->NewJSArrayBuffer(); 6008 i_isolate->factory()->NewJSArrayBuffer();
6177 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); 6009 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length);
6178 return Utils::ToLocal(obj); 6010 return Utils::ToLocal(obj);
6179 } 6011 }
6180 6012
6181 6013
6182 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) {
6183 return New(Isolate::GetCurrent(), data, byte_length);
6184 }
6185
6186
6187 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { 6014 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
6188 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6015 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6189 ASSERT(obj->buffer()->IsJSArrayBuffer()); 6016 ASSERT(obj->buffer()->IsJSArrayBuffer());
6190 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); 6017 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer()));
6191 return Utils::ToLocal(buffer); 6018 return Utils::ToLocal(buffer);
6192 } 6019 }
6193 6020
6194 6021
6195 size_t v8::ArrayBufferView::ByteOffset() { 6022 size_t v8::ArrayBufferView::ByteOffset() {
6196 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 6023 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
6509 } 6336 }
6510 6337
6511 6338
6512 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( 6339 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
6513 int64_t change_in_bytes) { 6340 int64_t change_in_bytes) {
6514 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); 6341 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
6515 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); 6342 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
6516 } 6343 }
6517 6344
6518 6345
6519 int64_t V8::AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes) {
6520 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6521 if (isolate == NULL || !isolate->IsInitialized()) {
6522 return 0;
6523 }
6524 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate);
6525 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
6526 }
6527
6528
6529 HeapProfiler* Isolate::GetHeapProfiler() { 6346 HeapProfiler* Isolate::GetHeapProfiler() {
6530 i::HeapProfiler* heap_profiler = 6347 i::HeapProfiler* heap_profiler =
6531 reinterpret_cast<i::Isolate*>(this)->heap_profiler(); 6348 reinterpret_cast<i::Isolate*>(this)->heap_profiler();
6532 return reinterpret_cast<HeapProfiler*>(heap_profiler); 6349 return reinterpret_cast<HeapProfiler*>(heap_profiler);
6533 } 6350 }
6534 6351
6535 6352
6536 CpuProfiler* Isolate::GetCpuProfiler() { 6353 CpuProfiler* Isolate::GetCpuProfiler() {
6537 i::CpuProfiler* cpu_profiler = 6354 i::CpuProfiler* cpu_profiler =
6538 reinterpret_cast<i::Isolate*>(this)->cpu_profiler(); 6355 reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
6791 str_ = i::NewArray<char>(length_ + 1); 6608 str_ = i::NewArray<char>(length_ + 1);
6792 str->WriteUtf8(str_); 6609 str->WriteUtf8(str_);
6793 } 6610 }
6794 6611
6795 6612
6796 String::Utf8Value::~Utf8Value() { 6613 String::Utf8Value::~Utf8Value() {
6797 i::DeleteArray(str_); 6614 i::DeleteArray(str_);
6798 } 6615 }
6799 6616
6800 6617
6801 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj)
6802 : str_(NULL), length_(0) {
6803 i::Isolate* isolate = i::Isolate::Current();
6804 if (obj.IsEmpty()) return;
6805 ENTER_V8(isolate);
6806 i::HandleScope scope(isolate);
6807 TryCatch try_catch;
6808 Handle<String> str = obj->ToString();
6809 if (str.IsEmpty()) return;
6810 length_ = str->Utf8Length();
6811 str_ = i::NewArray<char>(length_ + 1);
6812 str->WriteUtf8(str_);
6813 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_);
6814 }
6815
6816
6817 String::AsciiValue::~AsciiValue() {
6818 i::DeleteArray(str_);
6819 }
6820
6821
6822 String::Value::Value(v8::Handle<v8::Value> obj) 6618 String::Value::Value(v8::Handle<v8::Value> obj)
6823 : str_(NULL), length_(0) { 6619 : str_(NULL), length_(0) {
6824 i::Isolate* isolate = i::Isolate::Current(); 6620 i::Isolate* isolate = i::Isolate::Current();
6825 if (obj.IsEmpty()) return; 6621 if (obj.IsEmpty()) return;
6826 ENTER_V8(isolate); 6622 ENTER_V8(isolate);
6827 i::HandleScope scope(isolate); 6623 i::HandleScope scope(isolate);
6828 TryCatch try_catch; 6624 TryCatch try_catch;
6829 Handle<String> str = obj->ToString(); 6625 Handle<String> str = obj->ToString();
6830 if (str.IsEmpty()) return; 6626 if (str.IsEmpty()) return;
6831 length_ = str->Length(); 6627 length_ = str->Length();
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
7781 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7577 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7782 Address callback_address = 7578 Address callback_address =
7783 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7579 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7784 VMState<EXTERNAL> state(isolate); 7580 VMState<EXTERNAL> state(isolate);
7785 ExternalCallbackScope call_scope(isolate, callback_address); 7581 ExternalCallbackScope call_scope(isolate, callback_address);
7786 callback(info); 7582 callback(info);
7787 } 7583 }
7788 7584
7789 7585
7790 } } // namespace v8::internal 7586 } } // namespace v8::internal
OLDNEW
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698