OLD | NEW |
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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "api.h" | 28 #include "api.h" |
29 | 29 |
30 #include <math.h> // For isnan. | |
31 #include <string.h> // For memcpy, strlen. | 30 #include <string.h> // For memcpy, strlen. |
| 31 #include <cmath> // For isnan. |
32 #include "../include/v8-debug.h" | 32 #include "../include/v8-debug.h" |
33 #include "../include/v8-profiler.h" | 33 #include "../include/v8-profiler.h" |
34 #include "../include/v8-testing.h" | 34 #include "../include/v8-testing.h" |
35 #include "bootstrapper.h" | 35 #include "bootstrapper.h" |
36 #include "code-stubs.h" | 36 #include "code-stubs.h" |
37 #include "compiler.h" | 37 #include "compiler.h" |
38 #include "conversions-inl.h" | 38 #include "conversions-inl.h" |
39 #include "counters.h" | 39 #include "counters.h" |
40 #include "debug.h" | 40 #include "debug.h" |
41 #include "deoptimizer.h" | 41 #include "deoptimizer.h" |
(...skipping 2935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2977 } | 2977 } |
2978 LOG_API(isolate, "StrictEquals"); | 2978 LOG_API(isolate, "StrictEquals"); |
2979 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2979 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2980 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 2980 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
2981 // Must check HeapNumber first, since NaN !== NaN. | 2981 // Must check HeapNumber first, since NaN !== NaN. |
2982 if (obj->IsHeapNumber()) { | 2982 if (obj->IsHeapNumber()) { |
2983 if (!other->IsNumber()) return false; | 2983 if (!other->IsNumber()) return false; |
2984 double x = obj->Number(); | 2984 double x = obj->Number(); |
2985 double y = other->Number(); | 2985 double y = other->Number(); |
2986 // Must check explicitly for NaN:s on Windows, but -0 works fine. | 2986 // Must check explicitly for NaN:s on Windows, but -0 works fine. |
2987 return x == y && !isnan(x) && !isnan(y); | 2987 return x == y && !std::isnan(x) && !std::isnan(y); |
2988 } else if (*obj == *other) { // Also covers Booleans. | 2988 } else if (*obj == *other) { // Also covers Booleans. |
2989 return true; | 2989 return true; |
2990 } else if (obj->IsSmi()) { | 2990 } else if (obj->IsSmi()) { |
2991 return other->IsNumber() && obj->Number() == other->Number(); | 2991 return other->IsNumber() && obj->Number() == other->Number(); |
2992 } else if (obj->IsString()) { | 2992 } else if (obj->IsString()) { |
2993 return other->IsString() && | 2993 return other->IsString() && |
2994 i::String::cast(*obj)->Equals(i::String::cast(*other)); | 2994 i::String::cast(*obj)->Equals(i::String::cast(*other)); |
2995 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { | 2995 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { |
2996 return other->IsUndefined() || other->IsUndetectableObject(); | 2996 return other->IsUndefined() || other->IsUndetectableObject(); |
2997 } else { | 2997 } else { |
(...skipping 2563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5561 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5561 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5562 return Utils::ToLocal( | 5562 return Utils::ToLocal( |
5563 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 5563 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
5564 } | 5564 } |
5565 | 5565 |
5566 | 5566 |
5567 Local<v8::Value> v8::Date::New(double time) { | 5567 Local<v8::Value> v8::Date::New(double time) { |
5568 i::Isolate* isolate = i::Isolate::Current(); | 5568 i::Isolate* isolate = i::Isolate::Current(); |
5569 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); | 5569 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); |
5570 LOG_API(isolate, "Date::New"); | 5570 LOG_API(isolate, "Date::New"); |
5571 if (isnan(time)) { | 5571 if (std::isnan(time)) { |
5572 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 5572 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
5573 time = i::OS::nan_value(); | 5573 time = i::OS::nan_value(); |
5574 } | 5574 } |
5575 ENTER_V8(isolate); | 5575 ENTER_V8(isolate); |
5576 EXCEPTION_PREAMBLE(isolate); | 5576 EXCEPTION_PREAMBLE(isolate); |
5577 i::Handle<i::Object> obj = | 5577 i::Handle<i::Object> obj = |
5578 i::Execution::NewDate(time, &has_pending_exception); | 5578 i::Execution::NewDate(time, &has_pending_exception); |
5579 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); | 5579 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); |
5580 return Utils::ToLocal(obj); | 5580 return Utils::ToLocal(obj); |
5581 } | 5581 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5765 i::Vector<const char>(data, length)); | 5765 i::Vector<const char>(data, length)); |
5766 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 5766 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
5767 result->set_name(*name); | 5767 result->set_name(*name); |
5768 return Utils::ToLocal(result); | 5768 return Utils::ToLocal(result); |
5769 } | 5769 } |
5770 | 5770 |
5771 | 5771 |
5772 Local<Number> v8::Number::New(double value) { | 5772 Local<Number> v8::Number::New(double value) { |
5773 i::Isolate* isolate = i::Isolate::Current(); | 5773 i::Isolate* isolate = i::Isolate::Current(); |
5774 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); | 5774 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); |
5775 if (isnan(value)) { | 5775 if (std::isnan(value)) { |
5776 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 5776 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
5777 value = i::OS::nan_value(); | 5777 value = i::OS::nan_value(); |
5778 } | 5778 } |
5779 ENTER_V8(isolate); | 5779 ENTER_V8(isolate); |
5780 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); | 5780 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); |
5781 return Utils::NumberToLocal(result); | 5781 return Utils::NumberToLocal(result); |
5782 } | 5782 } |
5783 | 5783 |
5784 | 5784 |
5785 Local<Integer> v8::Integer::New(int32_t value) { | 5785 Local<Integer> v8::Integer::New(int32_t value) { |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7381 | 7381 |
7382 v->VisitPointers(blocks_.first(), first_block_limit_); | 7382 v->VisitPointers(blocks_.first(), first_block_limit_); |
7383 | 7383 |
7384 for (int i = 1; i < blocks_.length(); i++) { | 7384 for (int i = 1; i < blocks_.length(); i++) { |
7385 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7385 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
7386 } | 7386 } |
7387 } | 7387 } |
7388 | 7388 |
7389 | 7389 |
7390 } } // namespace v8::internal | 7390 } } // namespace v8::internal |
OLD | NEW |