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

Side by Side Diff: src/api.cc

Issue 390004: Fix warnings on Win64. (Closed)
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « src/allocation.cc ('k') | src/assembler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 19 matching lines...) Expand all
30 #include "api.h" 30 #include "api.h"
31 #include "arguments.h" 31 #include "arguments.h"
32 #include "bootstrapper.h" 32 #include "bootstrapper.h"
33 #include "compiler.h" 33 #include "compiler.h"
34 #include "debug.h" 34 #include "debug.h"
35 #include "execution.h" 35 #include "execution.h"
36 #include "global-handles.h" 36 #include "global-handles.h"
37 #include "platform.h" 37 #include "platform.h"
38 #include "serialize.h" 38 #include "serialize.h"
39 #include "snapshot.h" 39 #include "snapshot.h"
40 #include "utils.h"
40 #include "v8threads.h" 41 #include "v8threads.h"
41 #include "version.h" 42 #include "version.h"
42 43
43 44
44 #define LOG_API(expr) LOG(ApiEntryCall(expr)) 45 #define LOG_API(expr) LOG(ApiEntryCall(expr))
45 46
46 #ifdef ENABLE_HEAP_PROTECTION 47 #ifdef ENABLE_HEAP_PROTECTION
47 #define ENTER_V8 i::VMState __state__(i::OTHER) 48 #define ENTER_V8 i::VMState __state__(i::OTHER)
48 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) 49 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL)
49 #else 50 #else
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 } else { 2040 } else {
2040 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); 2041 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name);
2041 if (class_name->IsEqualTo(i::CStrVector("Arguments"))) { 2042 if (class_name->IsEqualTo(i::CStrVector("Arguments"))) {
2042 return v8::String::New("[object Object]"); 2043 return v8::String::New("[object Object]");
2043 2044
2044 } else { 2045 } else {
2045 const char* prefix = "[object "; 2046 const char* prefix = "[object ";
2046 Local<String> str = Utils::ToLocal(class_name); 2047 Local<String> str = Utils::ToLocal(class_name);
2047 const char* postfix = "]"; 2048 const char* postfix = "]";
2048 2049
2049 size_t prefix_len = strlen(prefix); 2050 int prefix_len = i::StrLength(prefix);
2050 size_t str_len = str->Length(); 2051 int str_len = str->Length();
2051 size_t postfix_len = strlen(postfix); 2052 int postfix_len = i::StrLength(postfix);
2052 2053
2053 size_t buf_len = prefix_len + str_len + postfix_len; 2054 int buf_len = static_cast<int>(prefix_len + str_len + postfix_len);
Lasse Reichstein 2009/11/10 16:37:41 Woops, cast no longer necessary. Will remove.
2054 char* buf = i::NewArray<char>(buf_len); 2055 char* buf = i::NewArray<char>(buf_len);
2055 2056
2056 // Write prefix. 2057 // Write prefix.
2057 char* ptr = buf; 2058 char* ptr = buf;
2058 memcpy(ptr, prefix, prefix_len * v8::internal::kCharSize); 2059 memcpy(ptr, prefix, prefix_len * v8::internal::kCharSize);
2059 ptr += prefix_len; 2060 ptr += prefix_len;
2060 2061
2061 // Write real content. 2062 // Write real content.
2062 str->WriteAscii(ptr, 0, str_len); 2063 str->WriteAscii(ptr, 0, str_len);
2063 ptr += str_len; 2064 ptr += str_len;
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2958 LOG_API("String::Empty()"); 2959 LOG_API("String::Empty()");
2959 return Utils::ToLocal(i::Factory::empty_symbol()); 2960 return Utils::ToLocal(i::Factory::empty_symbol());
2960 } 2961 }
2961 2962
2962 2963
2963 Local<String> v8::String::New(const char* data, int length) { 2964 Local<String> v8::String::New(const char* data, int length) {
2964 EnsureInitialized("v8::String::New()"); 2965 EnsureInitialized("v8::String::New()");
2965 LOG_API("String::New(char)"); 2966 LOG_API("String::New(char)");
2966 if (length == 0) return Empty(); 2967 if (length == 0) return Empty();
2967 ENTER_V8; 2968 ENTER_V8;
2968 if (length == -1) length = strlen(data); 2969 if (length == -1) length = i::StrLength(data);
2969 i::Handle<i::String> result = 2970 i::Handle<i::String> result =
2970 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); 2971 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length));
2971 return Utils::ToLocal(result); 2972 return Utils::ToLocal(result);
2972 } 2973 }
2973 2974
2974 2975
2975 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { 2976 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
2976 EnsureInitialized("v8::String::New()"); 2977 EnsureInitialized("v8::String::New()");
2977 LOG_API("String::New(char)"); 2978 LOG_API("String::New(char)");
2978 ENTER_V8; 2979 ENTER_V8;
2979 i::Handle<i::String> left_string = Utils::OpenHandle(*left); 2980 i::Handle<i::String> left_string = Utils::OpenHandle(*left);
2980 i::Handle<i::String> right_string = Utils::OpenHandle(*right); 2981 i::Handle<i::String> right_string = Utils::OpenHandle(*right);
2981 i::Handle<i::String> result = i::Factory::NewConsString(left_string, 2982 i::Handle<i::String> result = i::Factory::NewConsString(left_string,
2982 right_string); 2983 right_string);
2983 return Utils::ToLocal(result); 2984 return Utils::ToLocal(result);
2984 } 2985 }
2985 2986
2986 2987
2987 Local<String> v8::String::NewUndetectable(const char* data, int length) { 2988 Local<String> v8::String::NewUndetectable(const char* data, int length) {
2988 EnsureInitialized("v8::String::NewUndetectable()"); 2989 EnsureInitialized("v8::String::NewUndetectable()");
2989 LOG_API("String::NewUndetectable(char)"); 2990 LOG_API("String::NewUndetectable(char)");
2990 ENTER_V8; 2991 ENTER_V8;
2991 if (length == -1) length = strlen(data); 2992 if (length == -1) length = i::StrLength(data);
2992 i::Handle<i::String> result = 2993 i::Handle<i::String> result =
2993 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length)); 2994 i::Factory::NewStringFromUtf8(i::Vector<const char>(data, length));
2994 result->MarkAsUndetectable(); 2995 result->MarkAsUndetectable();
2995 return Utils::ToLocal(result); 2996 return Utils::ToLocal(result);
2996 } 2997 }
2997 2998
2998 2999
2999 static int TwoByteStringLength(const uint16_t* data) { 3000 static int TwoByteStringLength(const uint16_t* data) {
3000 int length = 0; 3001 int length = 0;
3001 while (data[length] != '\0') length++; 3002 while (data[length] != '\0') length++;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3049 i::ExternalTwoByteString* str = 3050 i::ExternalTwoByteString* str =
3050 i::ExternalTwoByteString::cast(*Utils::OpenHandle(*obj)); 3051 i::ExternalTwoByteString::cast(*Utils::OpenHandle(*obj));
3051 3052
3052 // External symbols are deleted when they are pruned out of the symbol 3053 // External symbols are deleted when they are pruned out of the symbol
3053 // table. Generally external symbols are not registered with the weak handle 3054 // table. Generally external symbols are not registered with the weak handle
3054 // callbacks unless they are upgraded to a symbol after being externalized. 3055 // callbacks unless they are upgraded to a symbol after being externalized.
3055 if (!str->IsSymbol()) { 3056 if (!str->IsSymbol()) {
3056 v8::String::ExternalStringResource* resource = 3057 v8::String::ExternalStringResource* resource =
3057 reinterpret_cast<v8::String::ExternalStringResource*>(parameter); 3058 reinterpret_cast<v8::String::ExternalStringResource*>(parameter);
3058 if (resource != NULL) { 3059 if (resource != NULL) {
3059 const size_t total_size = resource->length() * sizeof(*resource->data()); 3060 const int total_size =
3061 static_cast<int>(resource->length() * sizeof(*resource->data()));
3060 i::Counters::total_external_string_memory.Decrement(total_size); 3062 i::Counters::total_external_string_memory.Decrement(total_size);
3061 3063
3062 // The object will continue to live in the JavaScript heap until the 3064 // The object will continue to live in the JavaScript heap until the
3063 // handle is entirely cleaned out by the next GC. For example the 3065 // handle is entirely cleaned out by the next GC. For example the
3064 // destructor for the resource below could bring it back to life again. 3066 // destructor for the resource below could bring it back to life again.
3065 // Which is why we make sure to not have a dangling pointer here. 3067 // Which is why we make sure to not have a dangling pointer here.
3066 str->set_resource(NULL); 3068 str->set_resource(NULL);
3067 delete resource; 3069 delete resource;
3068 } 3070 }
3069 } 3071 }
3070 3072
3071 // In any case we do not need this handle any longer. 3073 // In any case we do not need this handle any longer.
3072 obj.Dispose(); 3074 obj.Dispose();
3073 } 3075 }
3074 3076
3075 3077
3076 static void DisposeExternalAsciiString(v8::Persistent<v8::Value> obj, 3078 static void DisposeExternalAsciiString(v8::Persistent<v8::Value> obj,
3077 void* parameter) { 3079 void* parameter) {
3078 ENTER_V8; 3080 ENTER_V8;
3079 i::ExternalAsciiString* str = 3081 i::ExternalAsciiString* str =
3080 i::ExternalAsciiString::cast(*Utils::OpenHandle(*obj)); 3082 i::ExternalAsciiString::cast(*Utils::OpenHandle(*obj));
3081 3083
3082 // External symbols are deleted when they are pruned out of the symbol 3084 // External symbols are deleted when they are pruned out of the symbol
3083 // table. Generally external symbols are not registered with the weak handle 3085 // table. Generally external symbols are not registered with the weak handle
3084 // callbacks unless they are upgraded to a symbol after being externalized. 3086 // callbacks unless they are upgraded to a symbol after being externalized.
3085 if (!str->IsSymbol()) { 3087 if (!str->IsSymbol()) {
3086 v8::String::ExternalAsciiStringResource* resource = 3088 v8::String::ExternalAsciiStringResource* resource =
3087 reinterpret_cast<v8::String::ExternalAsciiStringResource*>(parameter); 3089 reinterpret_cast<v8::String::ExternalAsciiStringResource*>(parameter);
3088 if (resource != NULL) { 3090 if (resource != NULL) {
3089 const size_t total_size = resource->length() * sizeof(*resource->data()); 3091 const int total_size =
3092 static_cast<int>(resource->length() * sizeof(*resource->data()));
3090 i::Counters::total_external_string_memory.Decrement(total_size); 3093 i::Counters::total_external_string_memory.Decrement(total_size);
3091 3094
3092 // The object will continue to live in the JavaScript heap until the 3095 // The object will continue to live in the JavaScript heap until the
3093 // handle is entirely cleaned out by the next GC. For example the 3096 // handle is entirely cleaned out by the next GC. For example the
3094 // destructor for the resource below could bring it back to life again. 3097 // destructor for the resource below could bring it back to life again.
3095 // Which is why we make sure to not have a dangling pointer here. 3098 // Which is why we make sure to not have a dangling pointer here.
3096 str->set_resource(NULL); 3099 str->set_resource(NULL);
3097 delete resource; 3100 delete resource;
3098 } 3101 }
3099 } 3102 }
3100 3103
3101 // In any case we do not need this handle any longer. 3104 // In any case we do not need this handle any longer.
3102 obj.Dispose(); 3105 obj.Dispose();
3103 } 3106 }
3104 3107
3105 3108
3106 Local<String> v8::String::NewExternal( 3109 Local<String> v8::String::NewExternal(
3107 v8::String::ExternalStringResource* resource) { 3110 v8::String::ExternalStringResource* resource) {
3108 EnsureInitialized("v8::String::NewExternal()"); 3111 EnsureInitialized("v8::String::NewExternal()");
3109 LOG_API("String::NewExternal"); 3112 LOG_API("String::NewExternal");
3110 ENTER_V8; 3113 ENTER_V8;
3111 const size_t total_size = resource->length() * sizeof(*resource->data()); 3114 const int total_size =
3115 static_cast<int>(resource->length() * sizeof(*resource->data()));
3112 i::Counters::total_external_string_memory.Increment(total_size); 3116 i::Counters::total_external_string_memory.Increment(total_size);
3113 i::Handle<i::String> result = NewExternalStringHandle(resource); 3117 i::Handle<i::String> result = NewExternalStringHandle(resource);
3114 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result); 3118 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result);
3115 i::GlobalHandles::MakeWeak(handle.location(), 3119 i::GlobalHandles::MakeWeak(handle.location(),
3116 resource, 3120 resource,
3117 &DisposeExternalString); 3121 &DisposeExternalString);
3118 return Utils::ToLocal(result); 3122 return Utils::ToLocal(result);
3119 } 3123 }
3120 3124
3121 3125
(...skipping 14 matching lines...) Expand all
3136 } 3140 }
3137 return result; 3141 return result;
3138 } 3142 }
3139 3143
3140 3144
3141 Local<String> v8::String::NewExternal( 3145 Local<String> v8::String::NewExternal(
3142 v8::String::ExternalAsciiStringResource* resource) { 3146 v8::String::ExternalAsciiStringResource* resource) {
3143 EnsureInitialized("v8::String::NewExternal()"); 3147 EnsureInitialized("v8::String::NewExternal()");
3144 LOG_API("String::NewExternal"); 3148 LOG_API("String::NewExternal");
3145 ENTER_V8; 3149 ENTER_V8;
3146 const size_t total_size = resource->length() * sizeof(*resource->data()); 3150 const int total_size =
3151 static_cast<int>(resource->length() * sizeof(*resource->data()));
3147 i::Counters::total_external_string_memory.Increment(total_size); 3152 i::Counters::total_external_string_memory.Increment(total_size);
3148 i::Handle<i::String> result = NewExternalAsciiStringHandle(resource); 3153 i::Handle<i::String> result = NewExternalAsciiStringHandle(resource);
3149 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result); 3154 i::Handle<i::Object> handle = i::GlobalHandles::Create(*result);
3150 i::GlobalHandles::MakeWeak(handle.location(), 3155 i::GlobalHandles::MakeWeak(handle.location(),
3151 resource, 3156 resource,
3152 &DisposeExternalAsciiString); 3157 &DisposeExternalAsciiString);
3153 return Utils::ToLocal(result); 3158 return Utils::ToLocal(result);
3154 } 3159 }
3155 3160
3156 3161
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 has_pending_exception = result.is_null(); 3263 has_pending_exception = result.is_null();
3259 EXCEPTION_BAILOUT_CHECK(Local<Object>()); 3264 EXCEPTION_BAILOUT_CHECK(Local<Object>());
3260 return Utils::ToLocal(result); 3265 return Utils::ToLocal(result);
3261 } 3266 }
3262 3267
3263 3268
3264 Local<String> v8::String::NewSymbol(const char* data, int length) { 3269 Local<String> v8::String::NewSymbol(const char* data, int length) {
3265 EnsureInitialized("v8::String::NewSymbol()"); 3270 EnsureInitialized("v8::String::NewSymbol()");
3266 LOG_API("String::NewSymbol(char)"); 3271 LOG_API("String::NewSymbol(char)");
3267 ENTER_V8; 3272 ENTER_V8;
3268 if (length == -1) length = strlen(data); 3273 if (length == -1) length = i::StrLength(data);
3269 i::Handle<i::String> result = 3274 i::Handle<i::String> result =
3270 i::Factory::LookupSymbol(i::Vector<const char>(data, length)); 3275 i::Factory::LookupSymbol(i::Vector<const char>(data, length));
3271 return Utils::ToLocal(result); 3276 return Utils::ToLocal(result);
3272 } 3277 }
3273 3278
3274 3279
3275 Local<Number> v8::Number::New(double value) { 3280 Local<Number> v8::Number::New(double value) {
3276 EnsureInitialized("v8::Number::New()"); 3281 EnsureInitialized("v8::Number::New()");
3277 if (isnan(value)) { 3282 if (isnan(value)) {
3278 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 3283 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
3857 3862
3858 3863
3859 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 3864 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
3860 HandleScopeImplementer* thread_local = 3865 HandleScopeImplementer* thread_local =
3861 reinterpret_cast<HandleScopeImplementer*>(storage); 3866 reinterpret_cast<HandleScopeImplementer*>(storage);
3862 thread_local->IterateThis(v); 3867 thread_local->IterateThis(v);
3863 return storage + ArchiveSpacePerThread(); 3868 return storage + ArchiveSpacePerThread();
3864 } 3869 }
3865 3870
3866 } } // namespace v8::internal 3871 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/allocation.cc ('k') | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698