| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "api.h" | 5 #include "api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #include <cmath> // For isnan. | |
| 9 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 10 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 11 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| 11 #include <cmath> // For isnan. |
| 12 #include "../include/v8-debug.h" | 12 #include "../include/v8-debug.h" |
| 13 #include "../include/v8-profiler.h" | 13 #include "../include/v8-profiler.h" |
| 14 #include "../include/v8-testing.h" | 14 #include "../include/v8-testing.h" |
| 15 #include "assert-scope.h" | 15 #include "assert-scope.h" |
| 16 #include "bootstrapper.h" | 16 #include "bootstrapper.h" |
| 17 #include "code-stubs.h" | 17 #include "code-stubs.h" |
| 18 #include "compiler.h" | 18 #include "compiler.h" |
| 19 #include "conversions-inl.h" | 19 #include "conversions-inl.h" |
| 20 #include "counters.h" | 20 #include "counters.h" |
| 21 #include "cpu-profiler.h" | 21 #include "cpu-profiler.h" |
| (...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); | 1743 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); |
| 1744 return ToApiHandle<UnboundScript>(result); | 1744 return ToApiHandle<UnboundScript>(result); |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 | 1747 |
| 1748 Local<Script> ScriptCompiler::Compile( | 1748 Local<Script> ScriptCompiler::Compile( |
| 1749 Isolate* v8_isolate, | 1749 Isolate* v8_isolate, |
| 1750 Source* source, | 1750 Source* source, |
| 1751 CompileOptions options) { | 1751 CompileOptions options) { |
| 1752 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 1752 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 1753 ON_BAILOUT(isolate, "v8::ScriptCompiler::Compile()", | 1753 ON_BAILOUT(isolate, "v8::ScriptCompiler::Compile()", return Local<Script>()); |
| 1754 return Local<Script>()); | |
| 1755 LOG_API(isolate, "ScriptCompiler::CompiletBound()"); | 1754 LOG_API(isolate, "ScriptCompiler::CompiletBound()"); |
| 1756 ENTER_V8(isolate); | 1755 ENTER_V8(isolate); |
| 1757 Local<UnboundScript> generic = | 1756 Local<UnboundScript> generic = CompileUnbound(v8_isolate, source, options); |
| 1758 CompileUnbound(v8_isolate, source, options); | |
| 1759 if (generic.IsEmpty()) return Local<Script>(); | 1757 if (generic.IsEmpty()) return Local<Script>(); |
| 1760 return generic->BindToCurrentContext(); | 1758 return generic->BindToCurrentContext(); |
| 1761 } | 1759 } |
| 1762 | 1760 |
| 1763 | 1761 |
| 1764 Local<Script> Script::Compile(v8::Handle<String> source, | 1762 Local<Script> Script::Compile(v8::Handle<String> source, |
| 1765 v8::ScriptOrigin* origin) { | 1763 v8::ScriptOrigin* origin) { |
| 1766 i::Handle<i::String> str = Utils::OpenHandle(*source); | 1764 i::Handle<i::String> str = Utils::OpenHandle(*source); |
| 1767 if (origin) { | 1765 if (origin) { |
| 1768 ScriptCompiler::Source script_source(source, *origin); | 1766 ScriptCompiler::Source script_source(source, *origin); |
| (...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3052 self, | 3050 self, |
| 3053 key_obj, | 3051 key_obj, |
| 3054 value_obj, | 3052 value_obj, |
| 3055 static_cast<PropertyAttributes>(attribs)).is_null(); | 3053 static_cast<PropertyAttributes>(attribs)).is_null(); |
| 3056 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3054 EXCEPTION_BAILOUT_CHECK(isolate, false); |
| 3057 return true; | 3055 return true; |
| 3058 } | 3056 } |
| 3059 | 3057 |
| 3060 | 3058 |
| 3061 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { | 3059 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { |
| 3062 return Set(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), | 3060 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), |
| 3063 value, DontEnum); | 3061 value, DontEnum); |
| 3064 } | 3062 } |
| 3065 | 3063 |
| 3066 | 3064 |
| 3067 bool v8::Object::ForceDelete(v8::Handle<Value> key) { | 3065 bool v8::Object::ForceDelete(v8::Handle<Value> key) { |
| 3068 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3066 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3069 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); | 3067 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); |
| 3070 ENTER_V8(isolate); | 3068 ENTER_V8(isolate); |
| 3071 i::HandleScope scope(isolate); | 3069 i::HandleScope scope(isolate); |
| 3072 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3070 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 3073 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3071 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj); | 3138 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj); |
| 3141 PropertyAttributes result = | 3139 PropertyAttributes result = |
| 3142 i::JSReceiver::GetPropertyAttribute(self, key_name); | 3140 i::JSReceiver::GetPropertyAttribute(self, key_name); |
| 3143 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE); | 3141 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE); |
| 3144 return static_cast<PropertyAttribute>(result); | 3142 return static_cast<PropertyAttribute>(result); |
| 3145 } | 3143 } |
| 3146 | 3144 |
| 3147 | 3145 |
| 3148 Local<Value> v8::Object::GetPrototype() { | 3146 Local<Value> v8::Object::GetPrototype() { |
| 3149 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3147 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3150 ON_BAILOUT(isolate, "v8::Object::GetPrototype()", | 3148 ON_BAILOUT(isolate, "v8::Object::GetPrototype()", return Local<v8::Value>()); |
| 3151 return Local<v8::Value>()); | |
| 3152 ENTER_V8(isolate); | 3149 ENTER_V8(isolate); |
| 3153 i::Handle<i::Object> self = Utils::OpenHandle(this); | 3150 i::Handle<i::Object> self = Utils::OpenHandle(this); |
| 3154 i::Handle<i::Object> result(self->GetPrototype(isolate), isolate); | 3151 i::Handle<i::Object> result(self->GetPrototype(isolate), isolate); |
| 3155 return Utils::ToLocal(result); | 3152 return Utils::ToLocal(result); |
| 3156 } | 3153 } |
| 3157 | 3154 |
| 3158 | 3155 |
| 3159 bool v8::Object::SetPrototype(Handle<Value> value) { | 3156 bool v8::Object::SetPrototype(Handle<Value> value) { |
| 3160 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3157 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3161 ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false); | 3158 ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3217 Local<Array> v8::Object::GetOwnPropertyNames() { | 3214 Local<Array> v8::Object::GetOwnPropertyNames() { |
| 3218 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3215 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3219 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyNames()", | 3216 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyNames()", |
| 3220 return Local<v8::Array>()); | 3217 return Local<v8::Array>()); |
| 3221 ENTER_V8(isolate); | 3218 ENTER_V8(isolate); |
| 3222 i::HandleScope scope(isolate); | 3219 i::HandleScope scope(isolate); |
| 3223 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3220 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 3224 EXCEPTION_PREAMBLE(isolate); | 3221 EXCEPTION_PREAMBLE(isolate); |
| 3225 i::Handle<i::FixedArray> value; | 3222 i::Handle<i::FixedArray> value; |
| 3226 has_pending_exception = !i::JSReceiver::GetKeys( | 3223 has_pending_exception = !i::JSReceiver::GetKeys( |
| 3227 self, i::JSReceiver::LOCAL_ONLY).ToHandle(&value); | 3224 self, i::JSReceiver::OWN_ONLY).ToHandle(&value); |
| 3228 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Array>()); | 3225 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Array>()); |
| 3229 // Because we use caching to speed up enumeration it is important | 3226 // Because we use caching to speed up enumeration it is important |
| 3230 // to never change the result of the basic enumeration function so | 3227 // to never change the result of the basic enumeration function so |
| 3231 // we clone the result. | 3228 // we clone the result. |
| 3232 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); | 3229 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); |
| 3233 i::Handle<i::JSArray> result = | 3230 i::Handle<i::JSArray> result = |
| 3234 isolate->factory()->NewJSArrayWithElements(elms); | 3231 isolate->factory()->NewJSArrayWithElements(elms); |
| 3235 return Utils::ToLocal(scope.CloseAndEscape(result)); | 3232 return Utils::ToLocal(scope.CloseAndEscape(result)); |
| 3236 } | 3233 } |
| 3237 | 3234 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3342 EXCEPTION_PREAMBLE(isolate); | 3339 EXCEPTION_PREAMBLE(isolate); |
| 3343 i::Handle<i::Object> obj; | 3340 i::Handle<i::Object> obj; |
| 3344 has_pending_exception = !i::Runtime::HasObjectProperty( | 3341 has_pending_exception = !i::Runtime::HasObjectProperty( |
| 3345 isolate, self, key_obj).ToHandle(&obj); | 3342 isolate, self, key_obj).ToHandle(&obj); |
| 3346 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3343 EXCEPTION_BAILOUT_CHECK(isolate, false); |
| 3347 return obj->IsTrue(); | 3344 return obj->IsTrue(); |
| 3348 } | 3345 } |
| 3349 | 3346 |
| 3350 | 3347 |
| 3351 bool v8::Object::HasPrivate(v8::Handle<Private> key) { | 3348 bool v8::Object::HasPrivate(v8::Handle<Private> key) { |
| 3349 // TODO(rossberg): this should use HasOwnProperty, but we'd need to |
| 3350 // generalise that to a (noy yet existant) Name argument first. |
| 3352 return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); | 3351 return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); |
| 3353 } | 3352 } |
| 3354 | 3353 |
| 3355 | 3354 |
| 3356 bool v8::Object::Delete(uint32_t index) { | 3355 bool v8::Object::Delete(uint32_t index) { |
| 3357 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3356 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3358 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()", | 3357 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()", |
| 3359 return false); | 3358 return false); |
| 3360 ENTER_V8(isolate); | 3359 ENTER_V8(isolate); |
| 3361 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 3360 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3445 setter_i, | 3444 setter_i, |
| 3446 static_cast<PropertyAttributes>(attribute), | 3445 static_cast<PropertyAttributes>(attribute), |
| 3447 settings); | 3446 settings); |
| 3448 } | 3447 } |
| 3449 | 3448 |
| 3450 | 3449 |
| 3451 bool v8::Object::HasOwnProperty(Handle<String> key) { | 3450 bool v8::Object::HasOwnProperty(Handle<String> key) { |
| 3452 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3451 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3453 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", | 3452 ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", |
| 3454 return false); | 3453 return false); |
| 3455 return i::JSReceiver::HasLocalProperty( | 3454 return i::JSReceiver::HasOwnProperty( |
| 3456 Utils::OpenHandle(this), Utils::OpenHandle(*key)); | 3455 Utils::OpenHandle(this), Utils::OpenHandle(*key)); |
| 3457 } | 3456 } |
| 3458 | 3457 |
| 3459 | 3458 |
| 3460 bool v8::Object::HasRealNamedProperty(Handle<String> key) { | 3459 bool v8::Object::HasRealNamedProperty(Handle<String> key) { |
| 3461 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3460 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3462 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", | 3461 ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", |
| 3463 return false); | 3462 return false); |
| 3464 return i::JSObject::HasRealNamedProperty(Utils::OpenHandle(this), | 3463 return i::JSObject::HasRealNamedProperty(Utils::OpenHandle(this), |
| 3465 Utils::OpenHandle(*key)); | 3464 Utils::OpenHandle(*key)); |
| (...skipping 4094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7560 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7559 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7561 Address callback_address = | 7560 Address callback_address = |
| 7562 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7561 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7563 VMState<EXTERNAL> state(isolate); | 7562 VMState<EXTERNAL> state(isolate); |
| 7564 ExternalCallbackScope call_scope(isolate, callback_address); | 7563 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7565 callback(info); | 7564 callback(info); |
| 7566 } | 7565 } |
| 7567 | 7566 |
| 7568 | 7567 |
| 7569 } } // namespace v8::internal | 7568 } } // namespace v8::internal |
| OLD | NEW |