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

Side by Side Diff: src/api.cc

Issue 238843002: remove some isolate::current uses from api.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « no previous file | 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 2256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 2267 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
2268 i::Handle<i::Object> is_constructor = 2268 i::Handle<i::Object> is_constructor =
2269 GetProperty(self, "isConstructor").ToHandleChecked(); 2269 GetProperty(self, "isConstructor").ToHandleChecked();
2270 return is_constructor->IsTrue(); 2270 return is_constructor->IsTrue();
2271 } 2271 }
2272 2272
2273 2273
2274 // --- J S O N --- 2274 // --- J S O N ---
2275 2275
2276 Local<Value> JSON::Parse(Local<String> json_string) { 2276 Local<Value> JSON::Parse(Local<String> json_string) {
2277 i::Isolate* isolate = i::Isolate::Current(); 2277 i::Handle<i::String> string = Utils::OpenHandle(*json_string);
2278 i::Isolate* isolate = string->GetIsolate();
2278 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse"); 2279 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse");
2279 ENTER_V8(isolate); 2280 ENTER_V8(isolate);
2280 i::HandleScope scope(isolate); 2281 i::HandleScope scope(isolate);
2281 i::Handle<i::String> source = 2282 i::Handle<i::String> source = i::String::Flatten(string);
2282 i::String::Flatten(Utils::OpenHandle(*json_string));
2283 EXCEPTION_PREAMBLE(isolate); 2283 EXCEPTION_PREAMBLE(isolate);
2284 i::MaybeHandle<i::Object> maybe_result = 2284 i::MaybeHandle<i::Object> maybe_result =
2285 source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source) 2285 source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source)
2286 : i::JsonParser<false>::Parse(source); 2286 : i::JsonParser<false>::Parse(source);
2287 i::Handle<i::Object> result; 2287 i::Handle<i::Object> result;
2288 has_pending_exception = !maybe_result.ToHandle(&result); 2288 has_pending_exception = !maybe_result.ToHandle(&result);
2289 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 2289 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2290 return Utils::ToLocal( 2290 return Utils::ToLocal(
2291 i::Handle<i::Object>::cast(scope.CloseAndEscape(result))); 2291 i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
2292 } 2292 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 return !i::IsMinusZero(value) && 2410 return !i::IsMinusZero(value) &&
2411 value >= 0 && 2411 value >= 0 &&
2412 value <= i::kMaxUInt32 && 2412 value <= i::kMaxUInt32 &&
2413 value == i::FastUI2D(i::FastD2UI(value)); 2413 value == i::FastUI2D(i::FastD2UI(value));
2414 } 2414 }
2415 return false; 2415 return false;
2416 } 2416 }
2417 2417
2418 2418
2419 bool Value::IsDate() const { 2419 bool Value::IsDate() const {
2420 i::Isolate* isolate = i::Isolate::Current();
2421 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2420 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2421 if (!obj->IsHeapObject()) return false;
2422 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2422 return obj->HasSpecificClassOf(isolate->heap()->Date_string()); 2423 return obj->HasSpecificClassOf(isolate->heap()->Date_string());
2423 } 2424 }
2424 2425
2425 2426
2426 bool Value::IsStringObject() const { 2427 bool Value::IsStringObject() const {
2427 i::Isolate* isolate = i::Isolate::Current();
2428 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2428 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2429 if (!obj->IsHeapObject()) return false;
2430 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2429 return obj->HasSpecificClassOf(isolate->heap()->String_string()); 2431 return obj->HasSpecificClassOf(isolate->heap()->String_string());
2430 } 2432 }
2431 2433
2432 2434
2433 bool Value::IsSymbolObject() const { 2435 bool Value::IsSymbolObject() const {
2434 // TODO(svenpanne): these and other test functions should be written such
2435 // that they do not use Isolate::Current().
2436 i::Isolate* isolate = i::Isolate::Current();
2437 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2436 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2437 if (!obj->IsHeapObject()) return false;
2438 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2438 return obj->HasSpecificClassOf(isolate->heap()->Symbol_string()); 2439 return obj->HasSpecificClassOf(isolate->heap()->Symbol_string());
2439 } 2440 }
2440 2441
2441 2442
2442 bool Value::IsNumberObject() const { 2443 bool Value::IsNumberObject() const {
2443 i::Isolate* isolate = i::Isolate::Current();
2444 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2444 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2445 if (!obj->IsHeapObject()) return false;
2446 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2445 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); 2447 return obj->HasSpecificClassOf(isolate->heap()->Number_string());
2446 } 2448 }
2447 2449
2448 2450
2449 static i::Object* LookupBuiltin(i::Isolate* isolate, 2451 static i::Object* LookupBuiltin(i::Isolate* isolate,
2450 const char* builtin_name) { 2452 const char* builtin_name) {
2451 i::Handle<i::String> string = 2453 i::Handle<i::String> string =
2452 isolate->factory()->InternalizeUtf8String(builtin_name); 2454 isolate->factory()->InternalizeUtf8String(builtin_name);
2453 return *i::Object::GetProperty( 2455 return *i::Object::GetProperty(
2454 isolate->js_builtins_object(), string).ToHandleChecked(); 2456 isolate->js_builtins_object(), string).ToHandleChecked();
2455 } 2457 }
2456 2458
2457 2459
2458 static bool CheckConstructor(i::Isolate* isolate, 2460 static bool CheckConstructor(i::Isolate* isolate,
2459 i::Handle<i::JSObject> obj, 2461 i::Handle<i::JSObject> obj,
2460 const char* class_name) { 2462 const char* class_name) {
2461 i::Object* constr = obj->map()->constructor(); 2463 i::Object* constr = obj->map()->constructor();
2462 if (!constr->IsJSFunction()) return false; 2464 if (!constr->IsJSFunction()) return false;
2463 i::JSFunction* func = i::JSFunction::cast(constr); 2465 i::JSFunction* func = i::JSFunction::cast(constr);
2464 return func->shared()->native() && 2466 return func->shared()->native() &&
2465 constr == LookupBuiltin(isolate, class_name); 2467 constr == LookupBuiltin(isolate, class_name);
2466 } 2468 }
2467 2469
2468 2470
2469 bool Value::IsNativeError() const { 2471 bool Value::IsNativeError() const {
2470 i::Isolate* isolate = i::Isolate::Current();
2471 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2472 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2472 if (obj->IsJSObject()) { 2473 if (obj->IsJSObject()) {
2473 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj)); 2474 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj));
2475 i::Isolate* isolate = js_obj->GetIsolate();
2474 return CheckConstructor(isolate, js_obj, "$Error") || 2476 return CheckConstructor(isolate, js_obj, "$Error") ||
2475 CheckConstructor(isolate, js_obj, "$EvalError") || 2477 CheckConstructor(isolate, js_obj, "$EvalError") ||
2476 CheckConstructor(isolate, js_obj, "$RangeError") || 2478 CheckConstructor(isolate, js_obj, "$RangeError") ||
2477 CheckConstructor(isolate, js_obj, "$ReferenceError") || 2479 CheckConstructor(isolate, js_obj, "$ReferenceError") ||
2478 CheckConstructor(isolate, js_obj, "$SyntaxError") || 2480 CheckConstructor(isolate, js_obj, "$SyntaxError") ||
2479 CheckConstructor(isolate, js_obj, "$TypeError") || 2481 CheckConstructor(isolate, js_obj, "$TypeError") ||
2480 CheckConstructor(isolate, js_obj, "$URIError"); 2482 CheckConstructor(isolate, js_obj, "$URIError");
2481 } else { 2483 } else {
2482 return false; 2484 return false;
2483 } 2485 }
2484 } 2486 }
2485 2487
2486 2488
2487 bool Value::IsBooleanObject() const { 2489 bool Value::IsBooleanObject() const {
2488 i::Isolate* isolate = i::Isolate::Current();
2489 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2490 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2491 if (!obj->IsHeapObject()) return false;
2492 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2490 return obj->HasSpecificClassOf(isolate->heap()->Boolean_string()); 2493 return obj->HasSpecificClassOf(isolate->heap()->Boolean_string());
2491 } 2494 }
2492 2495
2493 2496
2494 bool Value::IsRegExp() const { 2497 bool Value::IsRegExp() const {
2495 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2498 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2496 return obj->IsJSRegExp(); 2499 return obj->IsJSRegExp();
2497 } 2500 }
2498 2501
2499 2502
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 } 2568 }
2566 } 2569 }
2567 2570
2568 2571
2569 Local<Number> Value::ToNumber() const { 2572 Local<Number> Value::ToNumber() const {
2570 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2573 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2571 i::Handle<i::Object> num; 2574 i::Handle<i::Object> num;
2572 if (obj->IsNumber()) { 2575 if (obj->IsNumber()) {
2573 num = obj; 2576 num = obj;
2574 } else { 2577 } else {
2575 i::Isolate* isolate = i::Isolate::Current(); 2578 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2576 LOG_API(isolate, "ToNumber"); 2579 LOG_API(isolate, "ToNumber");
2577 ENTER_V8(isolate); 2580 ENTER_V8(isolate);
2578 EXCEPTION_PREAMBLE(isolate); 2581 EXCEPTION_PREAMBLE(isolate);
2579 has_pending_exception = !i::Execution::ToNumber( 2582 has_pending_exception = !i::Execution::ToNumber(
2580 isolate, obj).ToHandle(&num); 2583 isolate, obj).ToHandle(&num);
2581 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>()); 2584 EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
2582 } 2585 }
2583 return ToApiHandle<Number>(num); 2586 return ToApiHandle<Number>(num);
2584 } 2587 }
2585 2588
2586 2589
2587 Local<Integer> Value::ToInteger() const { 2590 Local<Integer> Value::ToInteger() const {
2588 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2591 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2589 i::Handle<i::Object> num; 2592 i::Handle<i::Object> num;
2590 if (obj->IsSmi()) { 2593 if (obj->IsSmi()) {
2591 num = obj; 2594 num = obj;
2592 } else { 2595 } else {
2593 i::Isolate* isolate = i::Isolate::Current(); 2596 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2594 LOG_API(isolate, "ToInteger"); 2597 LOG_API(isolate, "ToInteger");
2595 ENTER_V8(isolate); 2598 ENTER_V8(isolate);
2596 EXCEPTION_PREAMBLE(isolate); 2599 EXCEPTION_PREAMBLE(isolate);
2597 has_pending_exception = !i::Execution::ToInteger( 2600 has_pending_exception = !i::Execution::ToInteger(
2598 isolate, obj).ToHandle(&num); 2601 isolate, obj).ToHandle(&num);
2599 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>()); 2602 EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2600 } 2603 }
2601 return ToApiHandle<Integer>(num); 2604 return ToApiHandle<Integer>(num);
2602 } 2605 }
2603 2606
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2731 2734
2732 void v8::DataView::CheckCast(Value* that) { 2735 void v8::DataView::CheckCast(Value* that) {
2733 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2736 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2734 Utils::ApiCheck(obj->IsJSDataView(), 2737 Utils::ApiCheck(obj->IsJSDataView(),
2735 "v8::DataView::Cast()", 2738 "v8::DataView::Cast()",
2736 "Could not convert to DataView"); 2739 "Could not convert to DataView");
2737 } 2740 }
2738 2741
2739 2742
2740 void v8::Date::CheckCast(v8::Value* that) { 2743 void v8::Date::CheckCast(v8::Value* that) {
2741 i::Isolate* isolate = i::Isolate::Current();
2742 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2744 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2743 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), 2745 i::Isolate* isolate = NULL;
2746 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
2747 Utils::ApiCheck(isolate != NULL &&
2748 obj->HasSpecificClassOf(isolate->heap()->Date_string()),
2744 "v8::Date::Cast()", 2749 "v8::Date::Cast()",
2745 "Could not convert to date"); 2750 "Could not convert to date");
2746 } 2751 }
2747 2752
2748 2753
2749 void v8::StringObject::CheckCast(v8::Value* that) { 2754 void v8::StringObject::CheckCast(v8::Value* that) {
2750 i::Isolate* isolate = i::Isolate::Current();
2751 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2755 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2752 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), 2756 i::Isolate* isolate = NULL;
2757 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
2758 Utils::ApiCheck(isolate != NULL &&
2759 obj->HasSpecificClassOf(isolate->heap()->String_string()),
2753 "v8::StringObject::Cast()", 2760 "v8::StringObject::Cast()",
2754 "Could not convert to StringObject"); 2761 "Could not convert to StringObject");
2755 } 2762 }
2756 2763
2757 2764
2758 void v8::SymbolObject::CheckCast(v8::Value* that) { 2765 void v8::SymbolObject::CheckCast(v8::Value* that) {
2759 i::Isolate* isolate = i::Isolate::Current();
2760 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2766 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2761 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()), 2767 i::Isolate* isolate = NULL;
2768 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
2769 Utils::ApiCheck(isolate != NULL &&
2770 obj->HasSpecificClassOf(isolate->heap()->Symbol_string()),
2762 "v8::SymbolObject::Cast()", 2771 "v8::SymbolObject::Cast()",
2763 "Could not convert to SymbolObject"); 2772 "Could not convert to SymbolObject");
2764 } 2773 }
2765 2774
2766 2775
2767 void v8::NumberObject::CheckCast(v8::Value* that) { 2776 void v8::NumberObject::CheckCast(v8::Value* that) {
2768 i::Isolate* isolate = i::Isolate::Current();
2769 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2777 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2770 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), 2778 i::Isolate* isolate = NULL;
2779 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
2780 Utils::ApiCheck(isolate != NULL &&
2781 obj->HasSpecificClassOf(isolate->heap()->Number_string()),
2771 "v8::NumberObject::Cast()", 2782 "v8::NumberObject::Cast()",
2772 "Could not convert to NumberObject"); 2783 "Could not convert to NumberObject");
2773 } 2784 }
2774 2785
2775 2786
2776 void v8::BooleanObject::CheckCast(v8::Value* that) { 2787 void v8::BooleanObject::CheckCast(v8::Value* that) {
2777 i::Isolate* isolate = i::Isolate::Current();
2778 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2788 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2779 Utils::ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Boolean_string()), 2789 i::Isolate* isolate = NULL;
2790 if (obj->IsHeapObject()) isolate = i::HeapObject::cast(*obj)->GetIsolate();
2791 Utils::ApiCheck(isolate != NULL &&
2792 obj->HasSpecificClassOf(isolate->heap()->Boolean_string()),
2780 "v8::BooleanObject::Cast()", 2793 "v8::BooleanObject::Cast()",
2781 "Could not convert to BooleanObject"); 2794 "Could not convert to BooleanObject");
2782 } 2795 }
2783 2796
2784 2797
2785 void v8::RegExp::CheckCast(v8::Value* that) { 2798 void v8::RegExp::CheckCast(v8::Value* that) {
2786 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2799 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2787 Utils::ApiCheck(obj->IsJSRegExp(), 2800 Utils::ApiCheck(obj->IsJSRegExp(),
2788 "v8::RegExp::Cast()", 2801 "v8::RegExp::Cast()",
2789 "Could not convert to regular expression"); 2802 "Could not convert to regular expression");
2790 } 2803 }
2791 2804
2792 2805
2793 bool Value::BooleanValue() const { 2806 bool Value::BooleanValue() const {
2794 return Utils::OpenHandle(this)->BooleanValue(); 2807 return Utils::OpenHandle(this)->BooleanValue();
2795 } 2808 }
2796 2809
2797 2810
2798 double Value::NumberValue() const { 2811 double Value::NumberValue() const {
2799 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2812 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2800 i::Handle<i::Object> num; 2813 i::Handle<i::Object> num;
2801 if (obj->IsNumber()) { 2814 if (obj->IsNumber()) {
2802 num = obj; 2815 num = obj;
2803 } else { 2816 } else {
2804 i::Isolate* isolate = i::Isolate::Current(); 2817 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2805 LOG_API(isolate, "NumberValue"); 2818 LOG_API(isolate, "NumberValue");
2806 ENTER_V8(isolate); 2819 ENTER_V8(isolate);
2807 EXCEPTION_PREAMBLE(isolate); 2820 EXCEPTION_PREAMBLE(isolate);
2808 has_pending_exception = !i::Execution::ToNumber( 2821 has_pending_exception = !i::Execution::ToNumber(
2809 isolate, obj).ToHandle(&num); 2822 isolate, obj).ToHandle(&num);
2810 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value()); 2823 EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value());
2811 } 2824 }
2812 return num->Number(); 2825 return num->Number();
2813 } 2826 }
2814 2827
2815 2828
2816 int64_t Value::IntegerValue() const { 2829 int64_t Value::IntegerValue() const {
2817 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2830 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2818 i::Handle<i::Object> num; 2831 i::Handle<i::Object> num;
2819 if (obj->IsNumber()) { 2832 if (obj->IsNumber()) {
2820 num = obj; 2833 num = obj;
2821 } else { 2834 } else {
2822 i::Isolate* isolate = i::Isolate::Current(); 2835 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2823 LOG_API(isolate, "IntegerValue"); 2836 LOG_API(isolate, "IntegerValue");
2824 ENTER_V8(isolate); 2837 ENTER_V8(isolate);
2825 EXCEPTION_PREAMBLE(isolate); 2838 EXCEPTION_PREAMBLE(isolate);
2826 has_pending_exception = !i::Execution::ToInteger( 2839 has_pending_exception = !i::Execution::ToInteger(
2827 isolate, obj).ToHandle(&num); 2840 isolate, obj).ToHandle(&num);
2828 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2841 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2829 } 2842 }
2830 if (num->IsSmi()) { 2843 if (num->IsSmi()) {
2831 return i::Smi::cast(*num)->value(); 2844 return i::Smi::cast(*num)->value();
2832 } else { 2845 } else {
2833 return static_cast<int64_t>(num->Number()); 2846 return static_cast<int64_t>(num->Number());
2834 } 2847 }
2835 } 2848 }
2836 2849
2837 2850
2838 Local<Int32> Value::ToInt32() const { 2851 Local<Int32> Value::ToInt32() const {
2839 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2852 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2840 i::Handle<i::Object> num; 2853 i::Handle<i::Object> num;
2841 if (obj->IsSmi()) { 2854 if (obj->IsSmi()) {
2842 num = obj; 2855 num = obj;
2843 } else { 2856 } else {
2844 i::Isolate* isolate = i::Isolate::Current(); 2857 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2845 LOG_API(isolate, "ToInt32"); 2858 LOG_API(isolate, "ToInt32");
2846 ENTER_V8(isolate); 2859 ENTER_V8(isolate);
2847 EXCEPTION_PREAMBLE(isolate); 2860 EXCEPTION_PREAMBLE(isolate);
2848 has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num); 2861 has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num);
2849 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>()); 2862 EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
2850 } 2863 }
2851 return ToApiHandle<Int32>(num); 2864 return ToApiHandle<Int32>(num);
2852 } 2865 }
2853 2866
2854 2867
2855 Local<Uint32> Value::ToUint32() const { 2868 Local<Uint32> Value::ToUint32() const {
2856 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2869 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2857 i::Handle<i::Object> num; 2870 i::Handle<i::Object> num;
2858 if (obj->IsSmi()) { 2871 if (obj->IsSmi()) {
2859 num = obj; 2872 num = obj;
2860 } else { 2873 } else {
2861 i::Isolate* isolate = i::Isolate::Current(); 2874 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2862 LOG_API(isolate, "ToUInt32"); 2875 LOG_API(isolate, "ToUInt32");
2863 ENTER_V8(isolate); 2876 ENTER_V8(isolate);
2864 EXCEPTION_PREAMBLE(isolate); 2877 EXCEPTION_PREAMBLE(isolate);
2865 has_pending_exception = !i::Execution::ToUint32( 2878 has_pending_exception = !i::Execution::ToUint32(
2866 isolate, obj).ToHandle(&num); 2879 isolate, obj).ToHandle(&num);
2867 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); 2880 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2868 } 2881 }
2869 return ToApiHandle<Uint32>(num); 2882 return ToApiHandle<Uint32>(num);
2870 } 2883 }
2871 2884
2872 2885
2873 Local<Uint32> Value::ToArrayIndex() const { 2886 Local<Uint32> Value::ToArrayIndex() const {
2874 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2887 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2875 if (obj->IsSmi()) { 2888 if (obj->IsSmi()) {
2876 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj); 2889 if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
2877 return Local<Uint32>(); 2890 return Local<Uint32>();
2878 } 2891 }
2879 i::Isolate* isolate = i::Isolate::Current(); 2892 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2880 LOG_API(isolate, "ToArrayIndex"); 2893 LOG_API(isolate, "ToArrayIndex");
2881 ENTER_V8(isolate); 2894 ENTER_V8(isolate);
2882 EXCEPTION_PREAMBLE(isolate); 2895 EXCEPTION_PREAMBLE(isolate);
2883 i::Handle<i::Object> string_obj; 2896 i::Handle<i::Object> string_obj;
2884 has_pending_exception = !i::Execution::ToString( 2897 has_pending_exception = !i::Execution::ToString(
2885 isolate, obj).ToHandle(&string_obj); 2898 isolate, obj).ToHandle(&string_obj);
2886 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>()); 2899 EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2887 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); 2900 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj);
2888 uint32_t index; 2901 uint32_t index;
2889 if (str->AsArrayIndex(&index)) { 2902 if (str->AsArrayIndex(&index)) {
2890 i::Handle<i::Object> value; 2903 i::Handle<i::Object> value;
2891 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { 2904 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
2892 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); 2905 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate);
2893 } else { 2906 } else {
2894 value = isolate->factory()->NewNumber(index); 2907 value = isolate->factory()->NewNumber(index);
2895 } 2908 }
2896 return Utils::Uint32ToLocal(value); 2909 return Utils::Uint32ToLocal(value);
2897 } 2910 }
2898 return Local<Uint32>(); 2911 return Local<Uint32>();
2899 } 2912 }
2900 2913
2901 2914
2902 int32_t Value::Int32Value() const { 2915 int32_t Value::Int32Value() const {
2903 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2916 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2904 if (obj->IsSmi()) { 2917 if (obj->IsSmi()) {
2905 return i::Smi::cast(*obj)->value(); 2918 return i::Smi::cast(*obj)->value();
2906 } else { 2919 } else {
2907 i::Isolate* isolate = i::Isolate::Current(); 2920 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2908 LOG_API(isolate, "Int32Value (slow)"); 2921 LOG_API(isolate, "Int32Value (slow)");
2909 ENTER_V8(isolate); 2922 ENTER_V8(isolate);
2910 EXCEPTION_PREAMBLE(isolate); 2923 EXCEPTION_PREAMBLE(isolate);
2911 i::Handle<i::Object> num; 2924 i::Handle<i::Object> num;
2912 has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num); 2925 has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num);
2913 EXCEPTION_BAILOUT_CHECK(isolate, 0); 2926 EXCEPTION_BAILOUT_CHECK(isolate, 0);
2914 if (num->IsSmi()) { 2927 if (num->IsSmi()) {
2915 return i::Smi::cast(*num)->value(); 2928 return i::Smi::cast(*num)->value();
2916 } else { 2929 } else {
2917 return static_cast<int32_t>(num->Number()); 2930 return static_cast<int32_t>(num->Number());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 i::Handle<i::String>::cast(other)); 2987 i::Handle<i::String>::cast(other));
2975 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { 2988 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
2976 return other->IsUndefined() || other->IsUndetectableObject(); 2989 return other->IsUndefined() || other->IsUndetectableObject();
2977 } else { 2990 } else {
2978 return false; 2991 return false;
2979 } 2992 }
2980 } 2993 }
2981 2994
2982 2995
2983 bool Value::SameValue(Handle<Value> that) const { 2996 bool Value::SameValue(Handle<Value> that) const {
2984 i::Isolate* isolate = i::Isolate::Current();
2985 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(), 2997 if (!Utils::ApiCheck(this != NULL && !that.IsEmpty(),
2986 "v8::Value::SameValue()", 2998 "v8::Value::SameValue()",
2987 "Reading from empty handle")) { 2999 "Reading from empty handle")) {
2988 return false; 3000 return false;
2989 } 3001 }
2990 LOG_API(isolate, "SameValue");
2991 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3002 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2992 i::Handle<i::Object> other = Utils::OpenHandle(*that); 3003 i::Handle<i::Object> other = Utils::OpenHandle(*that);
2993 return obj->SameValue(*other); 3004 return obj->SameValue(*other);
2994 } 3005 }
2995 3006
2996 3007
2997 uint32_t Value::Uint32Value() const { 3008 uint32_t Value::Uint32Value() const {
2998 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3009 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2999 if (obj->IsSmi()) { 3010 if (obj->IsSmi()) {
3000 return i::Smi::cast(*obj)->value(); 3011 return i::Smi::cast(*obj)->value();
3001 } else { 3012 } else {
3002 i::Isolate* isolate = i::Isolate::Current(); 3013 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
3003 LOG_API(isolate, "Uint32Value"); 3014 LOG_API(isolate, "Uint32Value");
3004 ENTER_V8(isolate); 3015 ENTER_V8(isolate);
3005 EXCEPTION_PREAMBLE(isolate); 3016 EXCEPTION_PREAMBLE(isolate);
3006 i::Handle<i::Object> num; 3017 i::Handle<i::Object> num;
3007 has_pending_exception = !i::Execution::ToUint32( 3018 has_pending_exception = !i::Execution::ToUint32(
3008 isolate, obj).ToHandle(&num); 3019 isolate, obj).ToHandle(&num);
3009 EXCEPTION_BAILOUT_CHECK(isolate, 0); 3020 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3010 if (num->IsSmi()) { 3021 if (num->IsSmi()) {
3011 return i::Smi::cast(*num)->value(); 3022 return i::Smi::cast(*num)->value();
3012 } else { 3023 } else {
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after
5579 LOG_API(i_isolate, "NumberObject::New"); 5590 LOG_API(i_isolate, "NumberObject::New");
5580 ENTER_V8(i_isolate); 5591 ENTER_V8(i_isolate);
5581 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); 5592 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
5582 i::Handle<i::Object> obj = 5593 i::Handle<i::Object> obj =
5583 i::Object::ToObject(i_isolate, number).ToHandleChecked(); 5594 i::Object::ToObject(i_isolate, number).ToHandleChecked();
5584 return Utils::ToLocal(obj); 5595 return Utils::ToLocal(obj);
5585 } 5596 }
5586 5597
5587 5598
5588 double v8::NumberObject::ValueOf() const { 5599 double v8::NumberObject::ValueOf() const {
5589 i::Isolate* isolate = i::Isolate::Current();
5590 LOG_API(isolate, "NumberObject::NumberValue");
5591 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5600 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5592 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5601 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5602 i::Isolate* isolate = jsvalue->GetIsolate();
5603 LOG_API(isolate, "NumberObject::NumberValue");
5593 return jsvalue->value()->Number(); 5604 return jsvalue->value()->Number();
5594 } 5605 }
5595 5606
5596 5607
5597 Local<v8::Value> v8::BooleanObject::New(bool value) { 5608 Local<v8::Value> v8::BooleanObject::New(bool value) {
5598 i::Isolate* isolate = i::Isolate::Current(); 5609 i::Isolate* isolate = i::Isolate::Current();
5599 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()"); 5610 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()");
5600 LOG_API(isolate, "BooleanObject::New"); 5611 LOG_API(isolate, "BooleanObject::New");
5601 ENTER_V8(isolate); 5612 ENTER_V8(isolate);
5602 i::Handle<i::Object> boolean(value 5613 i::Handle<i::Object> boolean(value
5603 ? isolate->heap()->true_value() 5614 ? isolate->heap()->true_value()
5604 : isolate->heap()->false_value(), 5615 : isolate->heap()->false_value(),
5605 isolate); 5616 isolate);
5606 i::Handle<i::Object> obj = 5617 i::Handle<i::Object> obj =
5607 i::Object::ToObject(isolate, boolean).ToHandleChecked(); 5618 i::Object::ToObject(isolate, boolean).ToHandleChecked();
5608 return Utils::ToLocal(obj); 5619 return Utils::ToLocal(obj);
5609 } 5620 }
5610 5621
5611 5622
5612 bool v8::BooleanObject::ValueOf() const { 5623 bool v8::BooleanObject::ValueOf() const {
5613 i::Isolate* isolate = i::Isolate::Current();
5614 LOG_API(isolate, "BooleanObject::BooleanValue");
5615 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5624 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5616 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5625 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5626 i::Isolate* isolate = jsvalue->GetIsolate();
5627 LOG_API(isolate, "BooleanObject::BooleanValue");
5617 return jsvalue->value()->IsTrue(); 5628 return jsvalue->value()->IsTrue();
5618 } 5629 }
5619 5630
5620 5631
5621 Local<v8::Value> v8::StringObject::New(Handle<String> value) { 5632 Local<v8::Value> v8::StringObject::New(Handle<String> value) {
5622 i::Isolate* isolate = i::Isolate::Current(); 5633 i::Handle<i::String> string = Utils::OpenHandle(*value);
5634 i::Isolate* isolate = string->GetIsolate();
5623 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()"); 5635 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()");
5624 LOG_API(isolate, "StringObject::New"); 5636 LOG_API(isolate, "StringObject::New");
5625 ENTER_V8(isolate); 5637 ENTER_V8(isolate);
5626 i::Handle<i::Object> obj = i::Object::ToObject( 5638 i::Handle<i::Object> obj =
5627 isolate, Utils::OpenHandle(*value)).ToHandleChecked(); 5639 i::Object::ToObject(isolate, string).ToHandleChecked();
5628 return Utils::ToLocal(obj); 5640 return Utils::ToLocal(obj);
5629 } 5641 }
5630 5642
5631 5643
5632 Local<v8::String> v8::StringObject::ValueOf() const { 5644 Local<v8::String> v8::StringObject::ValueOf() const {
5633 i::Isolate* isolate = i::Isolate::Current();
5634 LOG_API(isolate, "StringObject::StringValue");
5635 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5645 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5636 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5646 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5647 i::Isolate* isolate = jsvalue->GetIsolate();
5648 LOG_API(isolate, "StringObject::StringValue");
5637 return Utils::ToLocal( 5649 return Utils::ToLocal(
5638 i::Handle<i::String>(i::String::cast(jsvalue->value()))); 5650 i::Handle<i::String>(i::String::cast(jsvalue->value())));
5639 } 5651 }
5640 5652
5641 5653
5642 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) { 5654 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) {
5643 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5655 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5644 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()"); 5656 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()");
5645 LOG_API(i_isolate, "SymbolObject::New"); 5657 LOG_API(i_isolate, "SymbolObject::New");
5646 ENTER_V8(i_isolate); 5658 ENTER_V8(i_isolate);
5647 i::Handle<i::Object> obj = i::Object::ToObject( 5659 i::Handle<i::Object> obj = i::Object::ToObject(
5648 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); 5660 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked();
5649 return Utils::ToLocal(obj); 5661 return Utils::ToLocal(obj);
5650 } 5662 }
5651 5663
5652 5664
5653 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { 5665 Local<v8::Symbol> v8::SymbolObject::ValueOf() const {
5654 i::Isolate* isolate = i::Isolate::Current();
5655 LOG_API(isolate, "SymbolObject::SymbolValue");
5656 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5666 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5657 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5667 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5668 i::Isolate* isolate = jsvalue->GetIsolate();
5669 LOG_API(isolate, "SymbolObject::SymbolValue");
5658 return Utils::ToLocal( 5670 return Utils::ToLocal(
5659 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); 5671 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value())));
5660 } 5672 }
5661 5673
5662 5674
5663 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { 5675 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
5664 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5676 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5665 EnsureInitializedForIsolate(i_isolate, "v8::Date::New()"); 5677 EnsureInitializedForIsolate(i_isolate, "v8::Date::New()");
5666 LOG_API(i_isolate, "Date::New"); 5678 LOG_API(i_isolate, "Date::New");
5667 if (std::isnan(time)) { 5679 if (std::isnan(time)) {
5668 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 5680 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
5669 time = i::OS::nan_value(); 5681 time = i::OS::nan_value();
5670 } 5682 }
5671 ENTER_V8(i_isolate); 5683 ENTER_V8(i_isolate);
5672 EXCEPTION_PREAMBLE(i_isolate); 5684 EXCEPTION_PREAMBLE(i_isolate);
5673 i::Handle<i::Object> obj; 5685 i::Handle<i::Object> obj;
5674 has_pending_exception = !i::Execution::NewDate( 5686 has_pending_exception = !i::Execution::NewDate(
5675 i_isolate, time).ToHandle(&obj); 5687 i_isolate, time).ToHandle(&obj);
5676 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); 5688 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>());
5677 return Utils::ToLocal(obj); 5689 return Utils::ToLocal(obj);
5678 } 5690 }
5679 5691
5680 5692
5681 double v8::Date::ValueOf() const { 5693 double v8::Date::ValueOf() const {
5682 i::Isolate* isolate = i::Isolate::Current();
5683 LOG_API(isolate, "Date::NumberValue");
5684 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5694 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5685 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); 5695 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj);
5696 i::Isolate* isolate = jsdate->GetIsolate();
5697 LOG_API(isolate, "Date::NumberValue");
5686 return jsdate->value()->Number(); 5698 return jsdate->value()->Number();
5687 } 5699 }
5688 5700
5689 5701
5690 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { 5702 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) {
5691 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5703 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5692 if (!i_isolate->IsInitialized()) return; 5704 if (!i_isolate->IsInitialized()) return;
5693 ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()", 5705 ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()",
5694 return); 5706 return);
5695 LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification"); 5707 LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification");
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
6079 i::Handle<i::Map> map = 6091 i::Handle<i::Map> map =
6080 i::JSObject::GetElementsTransitionMap(obj, elements_kind); 6092 i::JSObject::GetElementsTransitionMap(obj, elements_kind);
6081 i::JSObject::SetMapAndElements(obj, map, elements); 6093 i::JSObject::SetMapAndElements(obj, map, elements);
6082 return obj; 6094 return obj;
6083 } 6095 }
6084 6096
6085 6097
6086 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ 6098 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \
6087 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \ 6099 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
6088 size_t byte_offset, size_t length) { \ 6100 size_t byte_offset, size_t length) { \
6089 i::Isolate* isolate = i::Isolate::Current(); \ 6101 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \
6090 EnsureInitializedForIsolate(isolate, \ 6102 EnsureInitializedForIsolate(isolate, \
6091 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \ 6103 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
6092 LOG_API(isolate, \ 6104 LOG_API(isolate, \
6093 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \ 6105 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
6094 ENTER_V8(isolate); \ 6106 ENTER_V8(isolate); \
6095 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ 6107 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \
6096 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)", \ 6108 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)", \
6097 "length exceeds max allowed value")) { \ 6109 "length exceeds max allowed value")) { \
6098 return Local<Type##Array>(); \ 6110 return Local<Type##Array>(); \
6099 } \ 6111 } \
6100 i::Handle<i::JSTypedArray> obj = \ 6112 i::Handle<i::JSTypedArray> obj = \
6101 NewTypedArray<ctype, v8::kExternal##Type##Array, \ 6113 NewTypedArray<ctype, v8::kExternal##Type##Array, \
6102 i::EXTERNAL_##TYPE##_ELEMENTS>( \ 6114 i::EXTERNAL_##TYPE##_ELEMENTS>( \
6103 isolate, array_buffer, byte_offset, length); \ 6115 isolate, array_buffer, byte_offset, length); \
6104 return Utils::ToLocal##Type##Array(obj); \ 6116 return Utils::ToLocal##Type##Array(obj); \
6105 } 6117 }
6106 6118
6107 6119
6108 TYPED_ARRAYS(TYPED_ARRAY_NEW) 6120 TYPED_ARRAYS(TYPED_ARRAY_NEW)
6109 #undef TYPED_ARRAY_NEW 6121 #undef TYPED_ARRAY_NEW
6110 6122
6111 Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer, 6123 Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer,
6112 size_t byte_offset, size_t byte_length) { 6124 size_t byte_offset, size_t byte_length) {
6113 i::Isolate* isolate = i::Isolate::Current(); 6125 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6126 i::Isolate* isolate = buffer->GetIsolate();
6114 EnsureInitializedForIsolate( 6127 EnsureInitializedForIsolate(
6115 isolate, "v8::DataView::New(void*, size_t, size_t)"); 6128 isolate, "v8::DataView::New(void*, size_t, size_t)");
6116 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)"); 6129 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)");
6117 ENTER_V8(isolate); 6130 ENTER_V8(isolate);
6118 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView(); 6131 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView();
6119 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6120 SetupArrayBufferView( 6132 SetupArrayBufferView(
6121 isolate, obj, buffer, byte_offset, byte_length); 6133 isolate, obj, buffer, byte_offset, byte_length);
6122 return Utils::ToLocal(obj); 6134 return Utils::ToLocal(obj);
6123 } 6135 }
6124 6136
6125 6137
6126 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { 6138 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
6127 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6139 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6128 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); 6140 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
6129 LOG_API(i_isolate, "Symbol::New()"); 6141 LOG_API(i_isolate, "Symbol::New()");
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after
7656 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7668 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7657 Address callback_address = 7669 Address callback_address =
7658 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7670 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7659 VMState<EXTERNAL> state(isolate); 7671 VMState<EXTERNAL> state(isolate);
7660 ExternalCallbackScope call_scope(isolate, callback_address); 7672 ExternalCallbackScope call_scope(isolate, callback_address);
7661 callback(info); 7673 callback(info);
7662 } 7674 }
7663 7675
7664 7676
7665 } } // namespace v8::internal 7677 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698