WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
129114
jsc-cli needs a basic story for text IO
https://bugs.webkit.org/show_bug.cgi?id=129114
Summary
jsc-cli needs a basic story for text IO
Mark Hahnenberg
Reported
2014-02-20 12:25:34 PST
A simple solution that would get us pretty far would be to offer an IO module that was a higher-level wrapper around file-descriptor-based open/read/write/close OS level APIs.
Attachments
Patch
(48.43 KB, patch)
2014-02-23 10:12 PST
,
Mark Hahnenberg
no flags
Details
Formatted Diff
Diff
Patch
(47.12 KB, patch)
2014-02-26 09:46 PST
,
Mark Hahnenberg
oliver
: review-
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Mark Hahnenberg
Comment 1
2014-02-23 10:12:42 PST
Created
attachment 225008
[details]
Patch
Mark Hahnenberg
Comment 2
2014-02-23 12:02:12 PST
Comment on
attachment 225008
[details]
Patch Actually, this patch still has issues.
Mark Hahnenberg
Comment 3
2014-02-26 09:46:04 PST
Created
attachment 225261
[details]
Patch
Oliver Hunt
Comment 4
2014-02-28 10:23:37 PST
Comment on
attachment 225261
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=225261&action=review
How does this io performance compare to other scripting environments - it should be as fast or faster. r- due to buffer overflow
> Tools/jsc-cli/jsc-cli/lib/IOModule.m:102 > + char* buffer = (char*)malloc(sizeof(char) * (bytes + 1)); > + size_t result = fread(buffer, sizeof(char), bytes, handle.stream);
Hello buffer overflow :)
> Tools/jsc-cli/jsc-cli/lib/IOModule.m:106 > + setErrorWithErrno(); > + free(buffer); > + return (JSValue *)nil;
Please just throw an error on an io error, don't mess around with separate errors
> Tools/jsc-cli/jsc-cli/lib/IOModule.m:142 > + setErrorWithErrno();
again exception
> Tools/jsc-cli/jsc-cli/lib/IOModule.m:145 > + return [[NSString alloc] initWithBytes:line length:length encoding:NSUTF8StringEncoding];
Will this copy the bytes?
> Tools/jsc-cli/jsc-cli/lib/IOModule.m:151 > + setErrorWithErrno();
exception!
Oliver Hunt
Comment 5
2014-02-28 10:25:20 PST
Comment on
attachment 225261
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=225261&action=review
> Tools/jsc-cli/jsc-cli/lib/IOModule.m:150 > + int result = fclose(handle.stream); > + if (result != 0)
can we clear the stream field here? I don't want any bogus reuse to occur
Mark Hahnenberg
Comment 6
2014-02-28 10:31:13 PST
(In reply to
comment #4
)
> (From update of
attachment 225261
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=225261&action=review
> > How does this io performance compare to other scripting environments - it should be as fast or faster.
It's relatively slow due to lots of copying across the API boundary. I'm not sure we could avoid this without new API functionality.
> > > Tools/jsc-cli/jsc-cli/lib/IOModule.m:106 > > + setErrorWithErrno(); > > + free(buffer); > > + return (JSValue *)nil; > > Please just throw an error on an io error, don't mess around with separate errors
I'm not sure what you mean by this. Why should you get the same error if you don't have permission to access the file as when the file doesn't exist? That seems like a pure usability regression.
Mark Hahnenberg
Comment 7
2014-02-28 10:31:25 PST
(In reply to
comment #5
)
> (From update of
attachment 225261
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=225261&action=review
> > > Tools/jsc-cli/jsc-cli/lib/IOModule.m:150 > > + int result = fclose(handle.stream); > > + if (result != 0) > > can we clear the stream field here? I don't want any bogus reuse to occur
Will do.
Mark Hahnenberg
Comment 8
2014-02-28 10:34:36 PST
> > Tools/jsc-cli/jsc-cli/lib/IOModule.m:145 > > + return [[NSString alloc] initWithBytes:line length:length encoding:NSUTF8StringEncoding]; > > Will this copy the bytes?
Yep. - initWithBytesNoCopy:length:encoding: is the version that doesn't copy the bytes.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug