Chromium Code Reviews| 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 "src/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "src/json-parser.h" | 42 #include "src/json-parser.h" |
| 43 #include "src/messages.h" | 43 #include "src/messages.h" |
| 44 #include "src/parsing/parser.h" | 44 #include "src/parsing/parser.h" |
| 45 #include "src/parsing/scanner-character-streams.h" | 45 #include "src/parsing/scanner-character-streams.h" |
| 46 #include "src/pending-compilation-error-handler.h" | 46 #include "src/pending-compilation-error-handler.h" |
| 47 #include "src/profiler/cpu-profiler.h" | 47 #include "src/profiler/cpu-profiler.h" |
| 48 #include "src/profiler/heap-profiler.h" | 48 #include "src/profiler/heap-profiler.h" |
| 49 #include "src/profiler/heap-snapshot-generator-inl.h" | 49 #include "src/profiler/heap-snapshot-generator-inl.h" |
| 50 #include "src/profiler/profile-generator-inl.h" | 50 #include "src/profiler/profile-generator-inl.h" |
| 51 #include "src/profiler/sampler.h" | 51 #include "src/profiler/sampler.h" |
| 52 #include "src/property.h" | |
| 53 #include "src/property-descriptor.h" | 52 #include "src/property-descriptor.h" |
| 54 #include "src/property-details.h" | 53 #include "src/property-details.h" |
| 54 #include "src/property.h" | |
| 55 #include "src/prototype.h" | 55 #include "src/prototype.h" |
| 56 #include "src/runtime-profiler.h" | |
| 56 #include "src/runtime/runtime.h" | 57 #include "src/runtime/runtime.h" |
| 57 #include "src/runtime-profiler.h" | |
| 58 #include "src/simulator.h" | 58 #include "src/simulator.h" |
| 59 #include "src/snapshot/natives.h" | 59 #include "src/snapshot/natives.h" |
| 60 #include "src/snapshot/snapshot.h" | 60 #include "src/snapshot/snapshot.h" |
| 61 #include "src/startup-data-util.h" | 61 #include "src/startup-data-util.h" |
| 62 #include "src/tracing/trace-event.h" | 62 #include "src/tracing/trace-event.h" |
| 63 #include "src/unicode-inl.h" | 63 #include "src/unicode-inl.h" |
| 64 #include "src/v8.h" | 64 #include "src/v8.h" |
| 65 #include "src/v8threads.h" | 65 #include "src/v8threads.h" |
| 66 #include "src/version.h" | 66 #include "src/version.h" |
| 67 #include "src/vm-state-inl.h" | 67 #include "src/vm-state-inl.h" |
| 68 | 68 |
| 69 | |
| 70 namespace v8 { | 69 namespace v8 { |
| 71 | 70 |
| 72 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
| 73 | 72 |
| 74 | 73 |
| 75 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) | 74 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) |
| 76 | 75 |
| 77 | 76 |
| 78 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ | 77 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ |
| 79 bailout_value, HandleScopeClass, \ | 78 bailout_value, HandleScopeClass, \ |
| (...skipping 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2742 i::Handle<i::String> source = i::String::Flatten(string); | 2741 i::Handle<i::String> source = i::String::Flatten(string); |
| 2743 auto maybe = source->IsSeqOneByteString() | 2742 auto maybe = source->IsSeqOneByteString() |
| 2744 ? i::JsonParser<true>::Parse(source) | 2743 ? i::JsonParser<true>::Parse(source) |
| 2745 : i::JsonParser<false>::Parse(source); | 2744 : i::JsonParser<false>::Parse(source); |
| 2746 Local<Value> result; | 2745 Local<Value> result; |
| 2747 has_pending_exception = !ToLocal<Value>(maybe, &result); | 2746 has_pending_exception = !ToLocal<Value>(maybe, &result); |
| 2748 RETURN_ON_FAILED_EXECUTION(Value); | 2747 RETURN_ON_FAILED_EXECUTION(Value); |
| 2749 RETURN_ESCAPED(result); | 2748 RETURN_ESCAPED(result); |
| 2750 } | 2749 } |
| 2751 | 2750 |
| 2751 MaybeLocal<Value> JSON::Parse(Local<Context> context, | |
| 2752 Local<String> json_string) { | |
| 2753 PREPARE_FOR_EXECUTION(context, "JSON::Parse", Value); | |
| 2754 i::Handle<i::String> string = Utils::OpenHandle(*json_string); | |
| 2755 i::Handle<i::String> source = i::String::Flatten(string); | |
| 2756 auto maybe = source->IsSeqOneByteString() | |
| 2757 ? i::JsonParser<true>::Parse(source) | |
| 2758 : i::JsonParser<false>::Parse(source); | |
| 2759 Local<Value> result; | |
| 2760 has_pending_exception = !ToLocal<Value>(maybe, &result); | |
| 2761 RETURN_ON_FAILED_EXECUTION(Value); | |
| 2762 RETURN_ESCAPED(result); | |
| 2763 } | |
| 2752 | 2764 |
| 2753 Local<Value> JSON::Parse(Local<String> json_string) { | 2765 Local<Value> JSON::Parse(Local<String> json_string) { |
| 2754 auto isolate = reinterpret_cast<v8::Isolate*>( | 2766 RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); |
|
haavardm
2016/04/15 12:31:58
Is using an empty context correct here? (alternati
| |
| 2755 Utils::OpenHandle(*json_string)->GetIsolate()); | |
| 2756 RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value); | |
| 2757 } | 2767 } |
| 2758 | 2768 |
| 2769 MaybeLocal<String> JSON::Stringify(Local<Context> context, | |
| 2770 Local<Object> json_object) { | |
| 2771 PREPARE_FOR_EXECUTION(context, "JSON::Stringify", String); | |
| 2772 i::Handle<i::Object> object = Utils::OpenHandle(*json_object); | |
| 2773 i::Handle<i::Object> maybe; | |
| 2774 has_pending_exception = | |
| 2775 !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); | |
| 2776 RETURN_ON_FAILED_EXECUTION(String); | |
| 2777 Local<String> result; | |
| 2778 has_pending_exception = | |
| 2779 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); | |
| 2780 RETURN_ON_FAILED_EXECUTION(String); | |
| 2781 RETURN_ESCAPED(result); | |
| 2782 } | |
| 2759 | 2783 |
| 2760 // --- D a t a --- | 2784 // --- D a t a --- |
| 2761 | 2785 |
| 2762 bool Value::FullIsUndefined() const { | 2786 bool Value::FullIsUndefined() const { |
| 2763 bool result = Utils::OpenHandle(this)->IsUndefined(); | 2787 bool result = Utils::OpenHandle(this)->IsUndefined(); |
| 2764 DCHECK_EQ(result, QuickIsUndefined()); | 2788 DCHECK_EQ(result, QuickIsUndefined()); |
| 2765 return result; | 2789 return result; |
| 2766 } | 2790 } |
| 2767 | 2791 |
| 2768 | 2792 |
| (...skipping 6021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8790 Address callback_address = | 8814 Address callback_address = |
| 8791 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8815 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8792 VMState<EXTERNAL> state(isolate); | 8816 VMState<EXTERNAL> state(isolate); |
| 8793 ExternalCallbackScope call_scope(isolate, callback_address); | 8817 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8794 callback(info); | 8818 callback(info); |
| 8795 } | 8819 } |
| 8796 | 8820 |
| 8797 | 8821 |
| 8798 } // namespace internal | 8822 } // namespace internal |
| 8799 } // namespace v8 | 8823 } // namespace v8 |
| OLD | NEW |